package brad.zimmerman.dungeon.game;

import java.io.File;
import java.util.ArrayList;
import java.util.Random;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewManager;
import android.view.Window;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.SeekBar.OnSeekBarChangeListener;
import brad.zimmerman.dungeon.game.ClassAnimation.slopeAwesome;

public class ActivityGamePanel extends Activity {

	public ClassDrawingHolder Draws = new ClassDrawingHolder();
    ClassGameStats playerStats;
    public static ClassGameStats passedPlayerStats;
    int numTiles = ActivityDungeons.numTiles;
    int scale;
    Intent parentIntent;
    ClassBackgroundSound backgroundMusic;
    ClassDatabaseAct database;
    private View menuView;
    ClassSoundObjects sounds;
    Point point;
	int[] settings;
    int width,height;
    int textScaler;
    
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        parentIntent = this.getIntent();
        point = new Point(getDisplaySize(getWindowManager().getDefaultDisplay()));
        width = point.x;
    	height = point.y;
    	textScaler = -3 + (int)Math.pow(width/240,2);
    	scale =((int) Math.ceil((20*width/21)/numTiles));
    	backgroundMusic = new ClassBackgroundSound(this);
    	backgroundMusic.setVolume(ActivityDungeons.bkVolume);
    	playerStats = new ClassGameStats(width/(numTiles+1),ActivityDungeons.passedPlayerStats.player_race,
    			ActivityDungeons.passedPlayerStats.player_class,ActivityDungeons.passedPlayerStats.player_level,
    			ActivityDungeons.passedPlayerStats.backupData, ActivityDungeons.passedPlayerStats.sounds, ActivityDungeons.passedPlayerStats.unlockLevel,
    			ActivityDungeons.passedPlayerStats.difficulty);
    	//sounds = new soundObjects(this);
    	database = new ClassDatabaseAct(this);
    	sounds = playerStats.sounds;
    	sounds.setEnabled(true);
    	sounds.init();
    	settings = database.returnScoreValues(0, -1, -1);
    	menuView = new Panel(this);
    	setContentView(menuView);
    }
    
    /*Intent intent = new Intent(getBaseContext(), myMediaPlayer.class);
	//System.out.println(path);
	intent.putExtra("PATH_ID", aDirectory.getAbsolutePath());
	startActivity(intent);*/
	
    public void activityFunction(Context gameContext){
		//This function was made to pass the player class back and forth between 
		Intent i = new Intent(gameContext, ActivitySplashScreen.class);
		startActivityForResult(i,1);
		finish();
	}
    
    @Override
	public void onDestroy(){
		super.onDestroy(); 
		//This is here so that the VM does not run out of memory on a restart
		System.gc();
		backgroundMusic.stopBackground();
	}
	
    @Override
	public void onStop(){
		super.onStop(); 
		backgroundMusic.stopBackground();
	}
    
	@Override
	public void onPause(){
		super.onPause(); 
		backgroundMusic.stopBackground();
	}
	
	@Override
	public void onStart(){
		super.onStart(); 
		if(!backgroundMusic.running){
			backgroundMusic.setBackgroundNoise(playerStats.player_level);
			backgroundMusic.playBackground();
		}
	}
	
	@Override
	public void onResume(){
		super.onResume(); 
		if(!backgroundMusic.running){
			backgroundMusic.setBackgroundNoise(playerStats.player_level);
			backgroundMusic.playBackground();
		}
	}
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.layout.menu, menu);
        return true;
    }
    
    public void initializeSeekBar(SeekBar seekBar, final TextView text){
		seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {       
	    public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {     
	        // TODO Auto-generated method stub   
	    	/*if(text == findViewById(R.id.tiletext2)){
	    		text.setText(""+(progress+15));
	    	}
	    	else*/ if(text == findViewById(R.id.difftext2)){
	    		text.setText(""+(progress+50) +" %");
	    	}
	    	else{
	    		text.setText(""+progress);
	    	}

	    }

		public void onStartTrackingTouch(SeekBar arg0) {
			// TODO Auto-generated method stub
			
		}

		public void onStopTrackingTouch(SeekBar seekBar) {
			// TODO Auto-generated method stub
			
		}       
	}); 
}
    
    @Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    // Handle item selection
	    switch (item.getItemId()) {
	    case R.id.new_game:
	    	backgroundMusic.stopBackground();
	    	setContentView(R.layout.loadingscreen);
	    	finish();
	        return true;
	    case R.id.info:
	    	backgroundMusic.stopBackground();
	    	setContentView(R.layout.loadingscreen);

	    	/*playerStats = new gameStats(width/(numTiles+1),Dungeons.passedPlayerStats.player_race,
	    			Dungeons.passedPlayerStats.player_class,Dungeons.passedPlayerStats.player_level,
	    			Dungeons.passedPlayerStats.backupData, Dungeons.passedPlayerStats.sounds, Dungeons.passedPlayerStats.unlockLevel,
	    			Dungeons.passedPlayerStats.difficulty);

	    	menuView = new Panel(this);
	    	setContentView(menuView);*/
	    	Intent intent = getIntent();
	    	finish();
	    	startActivity(intent);
	    	//Intent i = getIntent();
	    	//System.out.println(getIntent().describeContents());
	    	//System.out.println(getIntent().toString());
	    	//i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	    	//i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
	    	//finish();
	    	//startActivity(i);
	    	//activityFunction(gamePanel.this);
	        //showInfo();
	    	//backgroundMusic.stopBackground();
	    	//setContentView(R.layout.loadingscreen);
	    	//finish();
	        return true;
	    case R.id.settings:
	    	//final View myView = (View)findViewById(R.layout.settingsmenu);
	    	//final ViewGroup vg = (ViewGroup)(new View(this));
	    	//vg.removeView(myView);
	    	if(backgroundMusic.running){
            	backgroundMusic.stopBackground();
            }
	    	setContentView(R.layout.settingsmenu);
	    	final Button button = (Button) findViewById(R.id.settingsSave);
	    	final Button button2 = (Button) findViewById(R.id.settingsCancel);
	    	//final SeekBar tileNumber = (SeekBar) findViewById(R.id.tileNumber);
	    	final SeekBar difficulty = (SeekBar) findViewById(R.id.difficulty);
	    	final SeekBar bkmusic = (SeekBar) findViewById(R.id.bkmusic);
	    	final SeekBar soundfx = (SeekBar) findViewById(R.id.soundfx);
	    	
	    	//TextView tileText = (TextView) findViewById(R.id.tiletext2);
	    	TextView diffText = (TextView) findViewById(R.id.difftext2);
	    	TextView bkText = (TextView) findViewById(R.id.bktext2);
	    	TextView sfxText = (TextView) findViewById(R.id.sfxtext2);
	    	
	    	//tileNumber.setMax(35);
	    	difficulty.setMax(100);
	    	bkmusic.setMax(100);
	    	soundfx.setMax(100);
	    	
	    	//tileNumber.setProgress(settings[4]-15);
	    	difficulty.setProgress(settings[5]);
	    	difficulty.setEnabled(false);
	    	bkmusic.setProgress((int)(settings[6]));
	    	soundfx.setProgress((int)(settings[7])); 
	    	
	    	//tileText.setText("" + (settings[4]));
	    	diffText.setText(""+(settings[5]+50) +" %");
	    	bkText.setText("" +(int)(settings[6]));
	    	sfxText.setText("" + (int)(settings[7]));
	    	
	    	//initializeSeekBar(tileNumber,tileText);
	    	initializeSeekBar(difficulty,diffText);
	    	initializeSeekBar(bkmusic,bkText);
	    	initializeSeekBar(soundfx,sfxText);
	    	
	    	
	        button.setOnClickListener(new View.OnClickListener() {
	            public void onClick(View v) {
	            	//Log.d("PROGRESS",""+bkmusic.getProgress());
	            	//Log.d("PROGRESS",""+soundfx.getProgress());
	            	//	numTiles = 15+tileNumber.getProgress();
	            	backgroundMusic.setVolume(bkmusic.getProgress());
	            	sounds.setVolume(soundfx.getProgress());
	            	
	    	    	database.InsertDatabase(0, 0, 0, 0, numTiles, difficulty.getProgress(), (int) backgroundMusic.getVolume(), (int) sounds.getVolume());
	        		settings = database.returnScoreValues(0, -1, -1);
	            	
	            	if(!backgroundMusic.running){
	        			backgroundMusic.setBackgroundNoise(playerStats.player_level);
	        			backgroundMusic.playBackground();
	        		}
	                //((ViewManager)myView.getParent()).removeView(myView);
	            	setContentView(menuView);
	            	}
	            }
	        );
	        button2.setOnClickListener(new View.OnClickListener() {
	            public void onClick(View v) {
	                //((ViewManager)myView.getParent()).removeView(myView);
	            	if(!backgroundMusic.running){
	        			backgroundMusic.setBackgroundNoise(playerStats.player_level);
	        			backgroundMusic.playBackground();
	        		}
	            	setContentView(menuView);
	            	}
	            }
	        );
	        return true;
	    case R.id.quit:
	    	backgroundMusic.stopBackground();
	    	setContentView(R.layout.loadingscreen);
	    	finish();
	        return true;
	    default:
	        return super.onOptionsItemSelected(item);
	    }
	}
    
	public String compileEnemyData(int enemy){
		String holder = "";
		
		holder += "Base Health: " + (Draws.enemyBaseStats[enemy][0])*10 + "%\n";
		holder += "Base Attack: " + (Draws.enemyBaseStats[enemy][1])*10 + "%\n";
		if(enemy!=0){
			holder += "Starting Lives: " + Draws.enemyBaseStats[enemy][2] + "\n";
		}else{
			holder += "Starting Lives: Same as level\n";
		}
		
		holder += "\nModifiers\n";
		
		if(Draws.enemyAbilityStats[enemy][0]){holder += "Mana Burn; ";}
		if(Draws.enemyAbilityStats[enemy][1]){holder += "Poison; ";}
		if(Draws.enemyAbilityStats[enemy][2]){holder += "25% Magic Resistance; ";}
		if(Draws.enemyAbilityStats[enemy][3]){holder += "50% Magic Resistance; ";}
		if(Draws.enemyAbilityStats[enemy][4]){holder += "25% Physical Resistance; ";}
		if(Draws.enemyAbilityStats[enemy][5]){holder += "50% Physical Resistance; ";}
		if(Draws.enemyAbilityStats[enemy][6]){holder += "Amnesia; ";}
		if(Draws.enemyAbilityStats[enemy][7]){holder += "Blind; ";}
		if(Draws.enemyAbilityStats[enemy][8]){holder += "Weakness; ";}
		if(Draws.enemyAbilityStats[enemy][9]){holder += "Magical Attack; ";}
		if(Draws.enemyAbilityStats[enemy][10]){holder += "Undead; ";}
		if(Draws.enemyAbilityStats[enemy][11]){holder += "Coward; ";}
		if(Draws.enemyAbilityStats[enemy][12]){holder += "Banish; ";}
		if(Draws.enemyAbilityStats[enemy][13]){holder += "First Strike; ";}
		if(Draws.enemyAbilityStats[enemy][14]){holder += "Static; ";}
		
		return holder;
	}
	
	public String compileRituals(int god){
		String holder = "";
		holder += "Cost " + Draws.ritualLevels[god][0]*10 + " Piety: "+ Draws.ritualDescriptions[god][2] +"\n";
		holder += "Cost " + Draws.ritualLevels[god][1]*10 + " Piety: "+ Draws.ritualDescriptions[god][3] + "\n";
		holder += "Cost " + Draws.ritualLevels[god][2]*10 + " Piety: "+ Draws.ritualDescriptions[god][4] + "\n";
		return holder;
	}
    
	@SuppressLint("NewApi")
	private static Point getDisplaySize(final Display display) {
	    final Point point = new Point();
	    //try {
	     //   display.getSize(point);
	    //} catch (java.lang.NoSuchMethodError ignore) { // Older device
	        point.x = display.getWidth();
	        point.y = display.getHeight();
	    //}
	    return point;
	}
	
    public class Panel extends SurfaceView implements SurfaceHolder.Callback {
    	
        private TutorialThread _thread;
        private ArrayList<ClassGraphicObject> _graphics = new ArrayList<ClassGraphicObject>();
        ClassReferenceImage ref = new ClassReferenceImage(numTiles,scale,point.x,point.y,playerStats);
        //CreateMap map = new CreateMap(numTiles);
        int[][] levelMap = ref.returnMap();
    	boolean changed, destroy, gameOver;
    	PointF pLocation, pMargins;
    	ClassCanvasChanged eventWatcher = new ClassCanvasChanged();
    	int boardX,boardY;
    	//This holds the second to last step for when the player engages in combat
    	int secondX, secondY;
    	boolean firstMove = true;
    	messageHolder tutorialMessages;
        int constant = (point.x/(numTiles+1));
        public ClassGraphicObject selector2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.selector));
        public ClassGraphicObject selector = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.selector2));
        public ClassGraphicObject prohibit = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.glyph_notused));
        public ClassGraphicObject graphic = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.classImages[playerStats.player_class]));
        public ClassGraphicObject footsteps = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.footsteps));
        public ClassGraphicObject trash = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.glyph_trash));
        public ClassGraphicObject darkfull = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.dark_full));
        public ClassGraphicObject darkhalf = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.dark_half));
        public ClassGraphicObject banner = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.obj_banner));
        
        public ClassGraphicObject endlost = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.endtitledeath));
        public ClassGraphicObject endwon = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.endtitlewin));

        public ClassGraphicObject floor = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.floorImages[playerStats.player_level]));
        public ClassGraphicObject wall = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.levelImages[playerStats.player_level]));
        public ClassGraphicObject enemy1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.enemyImages[Draws.levelMonsters[playerStats.player_level][0]]));
        public ClassGraphicObject enemy2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.enemyImages[Draws.levelMonsters[playerStats.player_level][1]]));
        public ClassGraphicObject enemy3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.enemyImages[Draws.levelMonsters[playerStats.player_level][2]]));
        public ClassGraphicObject enemy4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.enemyImages[Draws.levelMonsters[playerStats.player_level][3]]));
        public ClassGraphicObject enemy5 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.enemyImages[17]));
        
        public ClassGraphicObject icon1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[0]));
        public ClassGraphicObject icon2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[1]));
        public ClassGraphicObject icon3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[2]));
        public ClassGraphicObject icon4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[3]));
        public ClassGraphicObject icon5 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[4]));
        public ClassGraphicObject icon6 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[5]));
        public ClassGraphicObject icon7 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[6]));
        public ClassGraphicObject icon8 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.gameImages[7]));
        
        public ClassGraphicObject glyph1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[0]));
        public ClassGraphicObject glyph2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[1]));
        public ClassGraphicObject glyph3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[2]));
        public ClassGraphicObject glyph4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[3]));
        public ClassGraphicObject glyph5 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[4]));
        public ClassGraphicObject glyph6 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[5]));
        public ClassGraphicObject glyph7 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[6]));
        public ClassGraphicObject glyph8 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[7]));
        public ClassGraphicObject glyph9 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[8]));
        public ClassGraphicObject glyph10 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[9]));
        public ClassGraphicObject glyph11 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[10]));
        public ClassGraphicObject glyph12 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[11]));
        public ClassGraphicObject glyph13 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[12]));
        public ClassGraphicObject glyph14 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[13]));
        public ClassGraphicObject glyph15 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[14]));
        public ClassGraphicObject glyph16 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[15]));
        public ClassGraphicObject glyph17 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[16]));
        public ClassGraphicObject glyph18 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[17]));
        public ClassGraphicObject glyph19 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[18]));
        public ClassGraphicObject glyph20 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.glyphImages[19]));
        
        public ClassGraphicObject mod1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[0]));
        public ClassGraphicObject mod2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[1]));
        public ClassGraphicObject mod3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[2]));
        public ClassGraphicObject mod4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[3]));
        public ClassGraphicObject mod5 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[4]));
        public ClassGraphicObject mod6 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[5]));
        public ClassGraphicObject mod7 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[6]));
        public ClassGraphicObject mod8 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[7]));
        public ClassGraphicObject mod9 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[8]));
        public ClassGraphicObject mod10 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[9]));
        public ClassGraphicObject mod11 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[10]));
        public ClassGraphicObject mod12 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[11]));
        public ClassGraphicObject mod13 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[12]));
        public ClassGraphicObject mod14 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[13]));
        public ClassGraphicObject mod15 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[14]));
        public ClassGraphicObject mod16 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[15]));
        public ClassGraphicObject mod17 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.modImages[16]));
        
        public ClassGraphicObject haze1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.haze_enemy));
        public ClassGraphicObject haze2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.haze_powerup));
        public ClassGraphicObject haze3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.haze_glyph));
        
        public ClassGraphicObject loc1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.loc_shop));
        public ClassGraphicObject loc2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.loc_altar));
        public ClassGraphicObject loc3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.loc_altarworship));
        public ClassGraphicObject loc4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.loc_altarshroud));
        
        public ClassGraphicObject god1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[0]));
        public ClassGraphicObject god2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[1]));
        public ClassGraphicObject god3 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[2]));
        public ClassGraphicObject god4 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[3]));
        public ClassGraphicObject god5 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[4]));
        public ClassGraphicObject god6 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[5]));
        public ClassGraphicObject god7 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[6]));
        public ClassGraphicObject god8 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[7]));
        public ClassGraphicObject god9 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[8]));
        public ClassGraphicObject god10 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[9]));
        public ClassGraphicObject god11 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[10]));
        public ClassGraphicObject god12 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[11]));
        public ClassGraphicObject god13 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[12]));
        public ClassGraphicObject god14 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[13]));
        public ClassGraphicObject god15 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), Draws.godImages[14]));
        
        public ClassGraphicObject debris1 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.debris_blood));
        public ClassGraphicObject debris2 = new ClassGraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.wall_totem));

        ClassObjPosition playerPosition = new ClassObjPosition(numTiles, scale, point.x, point.y);
        ClassObjPosition playerPositionZoomed = new ClassObjPosition(20/2, scale, point.x, point.y,true);
        int playerPosX = ref.returnPlayerStartX(),playerPosY = ref.returnPlayerStartY();
        int cursorPositionX = ref.returnPlayerStartX(), cursorPositionY = ref.returnPlayerStartY();
        boolean playerAttacking;
        ClassMoveZoom zoomer= new ClassMoveZoom(numTiles,playerPosX,playerPosY);
        Bitmap[] tile,enemies,objects,glyphs,mods,location,gods,numbers, debris, haze,banners,enemiesStatic,
        objectsStatic,glyphsStatic,locationStatic,godsStatic,tileStatic;
        
        Bitmap[] tileHolder = {floor.getGraphic(),wall.getGraphic(), selector.getGraphic(), prohibit.getGraphic(), 
        		footsteps.getGraphic(),selector2.getGraphic(), trash.getGraphic(), darkhalf.getGraphic(), darkfull.getGraphic(), 
        		banner.getGraphic()};
        Bitmap[] enemiesHolder = {enemy1.getGraphic(), enemy2.getGraphic(), enemy3.getGraphic(), enemy4.getGraphic(), enemy5.getGraphic()};
        Bitmap[] objectsHolder = {icon1.getGraphic(), icon2.getGraphic(),icon3.getGraphic(),icon4.getGraphic(),icon5.getGraphic(),icon6.getGraphic(),icon7.getGraphic(),icon8.getGraphic()};
        Bitmap[] glyphsHolder = {glyph1.getGraphic(), glyph2.getGraphic(),glyph3.getGraphic(),glyph4.getGraphic(),glyph5.getGraphic(),glyph6.getGraphic(),glyph7.getGraphic(),glyph8.getGraphic(),
        		glyph9.getGraphic(),glyph10.getGraphic(),glyph11.getGraphic(),glyph12.getGraphic(),glyph13.getGraphic(),glyph14.getGraphic(),
        		glyph15.getGraphic(),glyph16.getGraphic(),glyph17.getGraphic(),glyph18.getGraphic(),glyph19.getGraphic(),glyph20.getGraphic()};
        Bitmap[] debrisHolder = {debris1.getGraphic(),debris2.getGraphic()};
        Bitmap[] modsHolder = {mod1.getGraphic(),mod2.getGraphic(),mod3.getGraphic(),mod4.getGraphic(),mod5.getGraphic(),
        		mod6.getGraphic(),mod7.getGraphic(),mod8.getGraphic(),mod9.getGraphic(), mod10.getGraphic(), mod11.getGraphic(), 
        		mod12.getGraphic(),mod13.getGraphic(),mod14.getGraphic(),mod15.getGraphic(),mod16.getGraphic(),mod17.getGraphic()};
        Bitmap[] hazeHolder = {haze1.getGraphic(),haze2.getGraphic(),haze3.getGraphic()};
        Bitmap[] locationHolder = {loc1.getGraphic(),loc2.getGraphic(),loc3.getGraphic(),loc4.getGraphic()};
        Bitmap[] godsHolder = {god1.getGraphic(),god2.getGraphic(),god3.getGraphic(),god4.getGraphic(),god5.getGraphic(),
        		god6.getGraphic(),god7.getGraphic(),god8.getGraphic(),god9.getGraphic(),god10.getGraphic(),
        		god11.getGraphic(),god12.getGraphic(),god13.getGraphic(),god14.getGraphic(),god15.getGraphic()
        		};
        Bitmap[] endBanners = {endlost.getGraphic(),endwon.getGraphic()};
        
        //Bitmap player = graphic.getGraphic();
        //The scale needs to be here so that the boxes are in the right area
        //System.out.println("Size: " + footfalls.size());
        
        
        
        public Panel(Context context) {
            super(context);
            System.out.println("Panel Initialized");
            getHolder().addCallback(this);
            playerAttacking = false;
            gameOver = false;
            pLocation = new PointF(0,0);
			pMargins = new PointF(0,0);
            _thread = new TutorialThread(getHolder(), this);
            setFocusable(true);
            
            staticImages((point.x/(20+1))*2);
            scaleImages(scale);            
            if (playerStats.makeDifficult){
            	ref.upgradeEnemies(1,1);
            }
            ref.setLevel(((float)Draws.levelDifficulty[playerStats.player_level]/(float)10) * (((float)playerStats.difficulty+50) / 100));
            //ref.setLevel(0);
            ref.updatePlayerSight(playerStats, ref.mapObject.getPlayerX(), ref.mapObject.getPlayerY());
            tutorialMessages = new messageHolder(context,scale,playerStats.player_level);
            if (playerStats.player_level == 0){
            	tutorialMessages.addMessage(Draws.levelStrings[playerStats.player_level],Draws.levelWelcome(playerStats.player_level,Draws.classStrings[playerStats.player_class]),0);
            }else{
            	tutorialMessages.showSingleMessageCharInfo(Draws.levelStrings[playerStats.player_level],
                		Draws.levelWelcome(playerStats.player_level,Draws.classStrings[playerStats.player_class]),graphic);
            }
            //tutorialMessages.addMessage("Welcome to Pocket Quest","The Purpose Of The Game Is To Find And Slay All Level 10 Monsters In Each Dungeon." +
            //		" Be Careful Though. You May Need To Level Up You Chracter A Bit Before You Are Ready To Take Them On. " +
            //		"Until 100% Difficulty, There Will Be Only 1 Level 10 Monster Per Level. Click Anywhere to Begin",0);
            //tutorialMessages.addMessage("Zoomin' In","Tap With Two Fingers To Zoom In And Out",1);
            //background.stopBackgroundMain();
            if(backgroundMusic.running && backgroundMusic.currentlyPlaying != playerStats.player_level){
            	backgroundMusic.stopBackground();
            }
            if(!backgroundMusic.running){
            	backgroundMusic.setBackgroundNoise(playerStats.player_level);
            	backgroundMusic.playBackground();
            }
            checkEnemyShroudStatus();
            System.out.println("Panel Finished");
            //leftHome = false;
        }
        
        public void testZoom(){
        	  zoomer.zoomIntoMatrix();
        	  //zoomer.zoomed = !zoomer.zoomed;
		      if (zoomer.getZoom()){
		    	  //constant *= 2;
		    	  scaleImages((point.x/(20+1))*2);
		      }else{
		    	  //constant /= 2;
		    	  scaleImages(scale);
		      }

        }
        
        public void staticImages(int imageScale){
        	mods = new Bitmap[modsHolder.length];
        	enemiesStatic = new Bitmap[enemiesHolder.length];
        	objectsStatic = new Bitmap[objectsHolder.length];
        	glyphsStatic = new Bitmap[glyphsHolder.length];
        	locationStatic = new Bitmap[locationHolder.length];
        	godsStatic = new Bitmap[godsHolder.length];
        	tileStatic = new Bitmap[tileHolder.length];
        	//banners = new Bitmap[endBanners.length];
        	
            for(int i = 0;i<mods.length;i++){
            	mods[i] = Bitmap.createBitmap(modsHolder[i], 0, 0,(modsHolder[i]).getWidth(),
            			(modsHolder[i]).getHeight(), mod1.returnMatrix((modsHolder[i]).getWidth(),
            					(modsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<enemiesStatic.length;i++){
            	enemiesStatic[i] = Bitmap.createBitmap(enemiesHolder[i], 0, 0,(enemiesHolder[i]).getWidth(),
            			(enemiesHolder[i]).getHeight(), enemy1.returnMatrix((enemiesHolder[i]).getWidth(),
            					(enemiesHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<objectsStatic.length;i++){
            	objectsStatic[i] = Bitmap.createBitmap(objectsHolder[i], 0, 0,(objectsHolder[i]).getWidth(),
            			(objectsHolder[i]).getHeight(), icon1.returnMatrix((objectsHolder[i]).getWidth(),
            					(objectsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<glyphsStatic.length;i++){
            	glyphsStatic[i] = Bitmap.createBitmap(glyphsHolder[i], 0, 0,(glyphsHolder[i]).getWidth(),
            			(glyphsHolder[i]).getHeight(), glyph1.returnMatrix((glyphsHolder[i]).getWidth(),
            					(glyphsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<locationStatic.length;i++){
            	locationStatic[i] = Bitmap.createBitmap(locationHolder[i], 0, 0,(locationHolder[i]).getWidth(),
            			(locationHolder[i]).getHeight(), loc1.returnMatrix((locationHolder[i]).getWidth(),
            					(locationHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<godsStatic.length;i++){
            	godsStatic[i] = Bitmap.createBitmap(godsHolder[i], 0, 0,(godsHolder[i]).getWidth(),
            			(godsHolder[i]).getHeight(), god1.returnMatrix((godsHolder[i]).getWidth(),
            					(godsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<tileStatic.length;i++){
            	tileStatic[i] = Bitmap.createBitmap(tileHolder[i], 0, 0,(tileHolder[i]).getWidth(), 
            			(tileHolder[i]).getHeight(), floor.returnMatrix((tileHolder[i]).getWidth(),
            					(tileHolder[i]).getHeight(),imageScale,false), true);
            }
            //for(int i = 0;i<endBanners.length;i++){
            //	banners[i] = Bitmap.createBitmap(endBanners[i], 0, 0,(endBanners[i]).getWidth(),
            //			(endBanners[i]).getHeight(), endwon.returnMatrix((endBanners[i]).getWidth(),
            //					(endBanners[i]).getHeight(),imageScale), true);
            //}
        }
        
    	public void scaleImages(int imageScale){
    		tile = new Bitmap[tileHolder.length];
        	enemies = new Bitmap[enemiesHolder.length];
        	objects = new Bitmap[objectsHolder.length];
        	glyphs = new Bitmap[glyphsHolder.length];
        	debris = new Bitmap[debrisHolder.length];
        	haze = new Bitmap[hazeHolder.length];
        	location = new Bitmap[locationHolder.length];
        	gods = new Bitmap[godsHolder.length];
        	
        	for(int i = 0;i<tile.length;i++){
            	tile[i] = Bitmap.createBitmap(tileHolder[i], 0, 0,(tileHolder[i]).getWidth(), 
            			(tileHolder[i]).getHeight(), floor.returnMatrix((tileHolder[i]).getWidth(),
            					(tileHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<enemies.length;i++){
            	enemies[i] = Bitmap.createBitmap(enemiesHolder[i], 0, 0,(enemiesHolder[i]).getWidth(),
            			(enemiesHolder[i]).getHeight(), enemy1.returnMatrix((enemiesHolder[i]).getWidth(),
            					(enemiesHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<objects.length;i++){
            	objects[i] = Bitmap.createBitmap(objectsHolder[i], 0, 0,(objectsHolder[i]).getWidth(),
            			(objectsHolder[i]).getHeight(), icon1.returnMatrix((objectsHolder[i]).getWidth(),
            					(objectsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<glyphs.length;i++){
            	glyphs[i] = Bitmap.createBitmap(glyphsHolder[i], 0, 0,(glyphsHolder[i]).getWidth(),
            			(glyphsHolder[i]).getHeight(), glyph1.returnMatrix((glyphsHolder[i]).getWidth(),
            					(glyphsHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<debris.length;i++){
            	debris[i] = Bitmap.createBitmap(debrisHolder[i], 0, 0,(debrisHolder[i]).getWidth(),
            			(debrisHolder[i]).getHeight(), debris1.returnMatrix((debrisHolder[i]).getWidth(),
            					(debrisHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<haze.length;i++){
            	haze[i] = Bitmap.createBitmap(hazeHolder[i], 0, 0,(hazeHolder[i]).getWidth(),
            			(hazeHolder[i]).getHeight(), haze1.returnMatrix((hazeHolder[i]).getWidth(),
            					(hazeHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<location.length;i++){
            	location[i] = Bitmap.createBitmap(locationHolder[i], 0, 0,(locationHolder[i]).getWidth(),
            			(locationHolder[i]).getHeight(), loc1.returnMatrix((locationHolder[i]).getWidth(),
            					(locationHolder[i]).getHeight(),imageScale,false), true);
            }
            for(int i = 0;i<gods.length;i++){
            	gods[i] = Bitmap.createBitmap(godsHolder[i], 0, 0,(godsHolder[i]).getWidth(),
            			(godsHolder[i]).getHeight(), god1.returnMatrix((godsHolder[i]).getWidth(),
            					(godsHolder[i]).getHeight(),imageScale,false), true);
            }
    	}
        
        public int figureRotation(int X, int Y, int prevX, int prevY){
        	//Above
        	if((prevY>Y) && (prevX == X)){
        		return 0;
        	}
        	//Below
        	else if((prevY<Y) && (prevX == X)){
        		return 180;
        	}
        	//Right
        	if((prevY==Y) && (prevX < X)){
        		return 90;
        	}
        	//Left
        	else{
        		return 270;
        	}
        }
        
        public ArrayList<ClassGraphicObject> shortestPath(int playerX, int playerY, int destX, int destY){
        	int movX, movY, goalX, goalY;
        	
        	ClassObjPosition boardPos;

        	boardPos = new ClassObjPosition(numTiles, scale, point.x, point.y);
        	
        	movX = boardPos.returnXMatrix(playerX, playerY);
        	movY = boardPos.returnYMatrix(playerX, playerY); 
        	
        	goalX = boardPos.returnXMatrix(destX, destY);
        	goalY = boardPos.returnYMatrix(destX, destY);
        	ArrayList<ClassGraphicObject> path = new ArrayList<ClassGraphicObject>();
        	
        	//This synchronized has to be here, or a deadlock is inevitable
        	ClassShortestPath shortPath = new ClassShortestPath(ref.map,ref.board.shroudPos,ref.returnEnemyMap(),new PointF(movX,movY), new PointF(goalX,goalY),numTiles);
        	ArrayList<PointF> foundPath = new ArrayList<PointF>(shortPath.returnPath());
        	
        	ClassGraphicObject cursor;
        	int location;
        	//System.out.println(foundPath.size());
        	if (foundPath.size()==0){

        	}else{
        	if (foundPath.size()>1){
        		location = foundPath.size()-2;
        		secondX = boardPos.findXBoard((int)foundPath.get(location).x, (int)foundPath.get(location).y);
    			secondY = boardPos.findYBoard((int)foundPath.get(location).x, (int)foundPath.get(location).y);
    		}else{
    			location = foundPath.size()-1;
    			secondX = boardPos.findXBoard((int)foundPath.get(location).x, (int)foundPath.get(location).y);
    			secondY = boardPos.findYBoard((int)foundPath.get(location).x, (int)foundPath.get(location).y);
    		}
        	
        	for (int i = 0; i<foundPath.size(); i++){
        		if (i==foundPath.size()-1){
        			cursor = new ClassGraphicObject(tile[2]);
        		}else{
        			cursor = new ClassGraphicObject(tile[4]);
        		}
        		cursor.getCoordinates().setX(boardPos.findXBoard((int)foundPath.get(i).x, (int)foundPath.get(i).y));
        		cursor.getCoordinates().setY(boardPos.findYBoard((int)foundPath.get(i).x, (int)foundPath.get(i).y));
        		if(i!=0){
        		path.add(i-1,cursor);
        		}
        	}
        	}
        	//This return assumes that the maze is solvable
        	//If the maze is not solvable, foundPath will be empty
        	return path;
        }
        
        public void addSteps(int steps){
        	playerStats.stepsTaken += steps;
        	if ((playerStats.loseHealthStatBonus != 0) && (playerStats.hasGoodEffects())){
        		playerStats.addHealth(playerStats.player_currenthealth, playerStats.getPlayerMaxHealth(), -playerStats.loseHealthStatBonus);
        	}
        	if (playerStats.loseManaStatBonus != 0 && (playerStats.hasGoodEffects())){
        		playerStats.addHealth(playerStats.player_currenthealth, playerStats.getPlayerMaxHealth(), -playerStats.loseManaStatBonus);
        	}
        	if ((playerStats.loseHealthStatAilment != 0) && (playerStats.hasBadEffects())){
        		playerStats.addHealth(playerStats.player_currenthealth, playerStats.getPlayerMaxHealth(), -playerStats.loseHealthStatAilment);
        	}
        	if (playerStats.loseManaStatAilment != 0 && (playerStats.hasBadEffects())){
        		playerStats.addHealth(playerStats.player_currenthealth, playerStats.getPlayerMaxHealth(), -playerStats.loseManaStatAilment);
        	}
    		if (playerStats.boxerFatigue){
    			playerStats.permModifier -= (float) (steps)/200;
    			if (playerStats.permModifier < -.5){
    				playerStats.permModifier = (float) -.5;
    			}
    		}
        }
        
        public void attackAround(PointF player, PointF enemy, float strength){
        	//PointF player = new PointF(playerPosition.findXBoard((int)playPos.x,(int)playPos.y),playerPosition.findYBoard((int)playPos.x,(int)playPos.y));
        	//System.out.println(player.x + " : " + player.y);
        	//System.out.println("Attacking: " + enemy.x + " : " + enemy.y);
        	if (player.x > 0 && player.x < numTiles && player.y > 0 && player.y < numTiles){
        	if(ref.enemyNum(
        			(int) (player.x),
        			(int) (player.y)) != 0 
        			&& !((int) (player.x) == enemy.x && (int) (player.y) == enemy.y)
        			){
        		//System.out.println("Enemy on: " + player.x + " : " + player.y);
				ref.returnEnemyObj((int) (player.x),(int) (player.y)).currentHealth -=
						//playerStats.calculateDamage(ref.returnEnemyObj((int) (player.x),(int) (player.y)), ref.exploredAround((int) (player.x), (int) (player.y)),strength)
						(float) playerStats.playerStrike(ref.returnEnemyObj((int) (player.x),(int) (player.y)), false) * strength;
						//);
				if(ref.returnEnemyObj((int) (player.x),(int) (player.y)).currentHealth < 1 && ref.returnEnemyObj((int) (player.x),(int) (player.y)).extraLives > 1){
					ref.returnEnemyObj((int) (player.x),(int) (player.y)).extraLives--;
					ref.returnEnemyObj((int) (player.x),(int) (player.y)).currentHealth = 1;
				}
				else if (ref.returnEnemyObj((int) (player.x),(int) (player.y)).currentHealth < 1 && ref.returnEnemyObj((int) (player.x), (int) (player.y)).extraLives<2){
					playerStats.killCalc(ref.returnEnemyObj((int) (player.x),(int) (player.y)).returnLevel(),ref.returnEnemyObj((int) (player.x),(int) (player.y)).undead,ref.returnEnemyObj((int) (player.x),(int) (player.y)).magicAttack);
					if (ref.enemyNum((int) (player.x),(int) (player.y)) != 18){
						ref.setDebrisObj( (int) (player.x),(int) (player.y), 1);
					}
					ref.setEnemyObj((int) (player.x),(int) (player.y),new ClassEnemyStats(0,0,0,0, false, false, false, false, false, false, false, false, false, false,false, false, false, false,false));
				}
			}
        	}
        }
        
        public void moveWithoutZoom(int boardX, int boardY){
        	
        	int enemyX;
        	int enemyY;
        	
        	if ((cursorPositionX!= playerPosition.findXScreen(boardX,boardY) || cursorPositionY!=playerPosition.findYScreen(boardX,boardY))
        			&& (playerPosX != playerPosition.findXScreen(boardX,boardY) || playerPosY!=playerPosition.findYScreen(boardX,boardY))
        			){changed = true;}
            if (playerPosition.returnMapIndex(playerPosition.findXScreen(boardX,boardY), playerPosition.findYScreen(boardX,boardY), levelMap) == 0 &&
            		ref.shroudNum(playerPosition.returnXMatrix(playerPosition.findXScreen(boardX,boardY),
            				playerPosition.findYScreen(boardX,boardY)), playerPosition.returnYMatrix(playerPosition.findXScreen(boardX,boardY),
            						playerPosition.findYScreen(boardX,boardY))) == 0){
            	//cursorPositionX= playerPosition.findXScreen(boardX,boardY);
            	//cursorPositionY= playerPosition.findYScreen(boardX,boardY);
            	
            //If the user has not clicked off of the screen, or on a wall
        	if (playerPosition.findXScreen(boardX,boardY) != 0 && playerPosition.findYScreen(boardX,boardY) != 0 
        			&& playerPosition.returnMapIndex(playerPosX, playerPosY, levelMap)== 0){
        		playerStats.stepTaken();
        		cursorPositionX= playerPosition.findXScreen(boardX,boardY);
            	cursorPositionY= playerPosition.findYScreen(boardX,boardY);
        		if (changed){
        			//tile[0].getCoordinates().setX(cursorPositionX);
            		//tile[0].getCoordinates().setY(cursorPositionY);

            		ArrayList<ClassGraphicObject> footfalls = new ArrayList<ClassGraphicObject>(
            				shortestPath(playerPosX, playerPosY, cursorPositionX, cursorPositionY)
            				);
            		//System.out.println("Size: " + footfalls.size());
            		
            		graphic.getCoordinates().setX(playerPosX);
        			graphic.getCoordinates().setY(playerPosY);
            		//There needs to be code here for connecting the destination with the current position
            		//done
            		_graphics.clear();
            		//_graphics.add(tile[0]);
                	_graphics.add(graphic);
            		if(footfalls.size() < 1){
            			cursorPositionX= playerPosX;
                    	cursorPositionY= playerPosY;
            		}

            		for (int i = 0 ; i < footfalls.size(); i++){
            			//add all of the footfalls to the list
            			//if the footfalls pass through an enemy, stop the cursor on the enemy

            			_graphics.add(footfalls.get(i));
            		}
            		sounds.playSound(5);
        		}
        		else{
        			enemyX = playerPosition.returnXMatrix(cursorPositionX,cursorPositionY);
    	        	enemyY = playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
        			if (ref.enemyNum(enemyX,enemyY)!=0){
        				playerAttacking = true;
        				//This means that the player is attacking an enemy
        				//tutorialMessages.addMessage("Attacking An Enemy","You Have Attacked An Enemy. " +
        				//		" The Predicted Outcome Of Your Actions Is Displayed On The Bottom Right Hand Side Of The Screen",6);
        				
        				//The attack
        				ref.setEnemyObj(enemyX,enemyY,playerStats.calculateDamage(ref.returnEnemyObj(enemyX,enemyY), ref.exploredAround(enemyX, enemyY),1));
        				
        				
        				if (playerStats.areaAttack){
        					PointF playerPos = new PointF(playerPosition.returnXMatrix(secondX,secondY),playerPosition.returnYMatrix(secondX,secondY));
        					attackAround(new PointF(playerPos.x-1,playerPos.y+1),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x-1,playerPos.y),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x-1,playerPos.y-1),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x,playerPos.y+1),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x,playerPos.y-1),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x+1,playerPos.y+1),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x+1,playerPos.y),new PointF(enemyX,enemyY),(float) .25);
        					attackAround(new PointF(playerPos.x+1,playerPos.y-1),new PointF(enemyX,enemyY),(float) .25);
        				}
        				
        				
        				//If the player kills the enemy...
        				if ((ref.returnEnemyObj(enemyX,enemyY).currentHealth < 1 || ref.returnEnemyObj(enemyX,enemyY).petrified) && ((playerStats.player_currenthealth > 0)
        						||(playerStats.player_currenthealth <= 0 && playerStats.extraLife))){
        					if (ref.returnEnemyObj(enemyX,enemyY).extraLives == 1){
        						if (playerStats.player_currenthealth <= 0 && playerStats.extraLife){
        							playerStats.player_currenthealth = 1;
        							playerStats.extraLife = false;
        						}
        						int animX = cursorPositionX, animY = cursorPositionY;
                    			if(zoomer.getZoom()){
                    				int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerX()-1);
                    				int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerY()-1);
                    				animX = playerPositionZoomed.findXBoard(convertX, convertY);
                    				animY = playerPositionZoomed.findYBoard(convertX, convertY);
                    			}
        						playerStats.shroudAnimations.addKillBubbles(animX+constant/2, animY+constant/2, 0);
        						if(!ref.returnEnemyObj(enemyX,enemyY).petrified){
        							//tutorialMessages.addMessage("Killed An Enemy","You Have Killed An Enemy. " +
        							//		"The Higher The Level Difference Between You And Your Foe, The More Experience You Gain. Only Killing Enemies With Attacks Gives Blood Pools",3);
        							//tutorialMessages.addMessage("Gaining Experience","The Experience You Gain Is Equal To The Level Of The Enemy You Just Killed. It Is Displayed In The Green" +
        							//		" Bar Right Above Your Character's Health. When Your Green Bar Fills Up, Your Character Will Gain A Level. Gaining A Level Upgrades Your Character " +
        							//		"And Cures All Current Status Ailments",8);
        							//tutorialMessages.addMessage("Forget Your Class? Race? God?","Tapping The Player Icon On The Bottom Of Your Screen Will Give You A Quick Overview Of Your Current Race, Class, and " +
        							//		"God Statistics",7);
        							if(playerStats.killCalc(ref.returnEnemyObj(enemyX,enemyY).returnLevel(),ref.returnEnemyObj(enemyX,enemyY).undead,ref.returnEnemyObj(enemyX,enemyY).magicAttack)){
        							//	for(int i =((constant*6)+3); i < ((constant*13)-3); i+=5){
        							//		playerStats.shroudAnimations.addKillBubbles(i, (((27)* constant) + (3*constant)/4)+3, 0,true);
        							//	}
        								//health red
        								//playerStats.shroudAnimations.addDamageAnimation((constant*7), (((30)* constant)+ (7*constant)/10),1,"+"+(int)(10 - playerStats.sickly),20,true);
        								//mana blue
        								//playerStats.shroudAnimations.addDamageAnimation((constant*7), (((32)* constant)+ (7*constant)/10),2,"+"+(int)(5 + playerStats.xtraMana),20,true);
        								//attack green
        								//playerStats.shroudAnimations.addDamageAnimation((constant*4),(constant*28)+constant/2,0,"+"+(int)(5 + playerStats.xtraStrength),20,true);
        							}
        						}else{
        							//tutorialMessages.addMessage("Petrified An Enemy",
        							//		"You Have Petrified An Enemy. You Recieve No Bonus Experience Or Blood Pool For Doing This",4);
        							if(playerStats.addEXP(ref.returnEnemyObj(enemyX,enemyY).level)){
        							//	for(int i =((constant*6)+3); i < ((constant*13)-3); i+=5){
        							//		playerStats.shroudAnimations.addKillBubbles(i, (((27)* constant) + (3*constant)/4)+3, 0,true);
        							//	}
        								//health red
        								//playerStats.shroudAnimations.addDamageAnimation((constant*7), (((30)* constant)+ (7*constant)/10),1,"+"+(int)(10 - playerStats.sickly),20,true);
        								//mana blue
        								//playerStats.shroudAnimations.addDamageAnimation((constant*7), (((32)* constant)+ (7*constant)/10),2,"+"+(int)(5 + playerStats.xtraMana),20,true);
        								//attack green
        								//playerStats.shroudAnimations.addDamageAnimation((constant*4),(constant*28)+constant/2,0,"+"+(int)(5 + playerStats.xtraStrength),20,true);
        								
        							}
        						}

        						addSteps(_graphics.size()-1);
        						playerPosX = secondX;
        						playerPosY = secondY;
        						if (ref.enemyNum(enemyX,enemyY) != 18 && !ref.returnEnemyObj(enemyX,enemyY).petrified){
        							ref.setDebrisObj( playerPosition.returnXMatrix(cursorPositionX,cursorPositionY), playerPosition.returnYMatrix(cursorPositionX,cursorPositionY), 1);
        						}else if(ref.returnEnemyObj(enemyX,enemyY).petrified){
        							ref.map[enemyX][enemyY] = 1;
        						}

        						ref.mapObject.setPlayerX(playerPosition.returnXMatrix(playerPosX,playerPosY));
        						ref.mapObject.setPlayerY(playerPosition.returnYMatrix(playerPosX,playerPosY));
        						ref.setEnemyObj(enemyX,enemyY,new ClassEnemyStats(0,0,0,0, false, false, false, false, false, false, false, false, false, false,false, false, false, false,false));
        						_graphics.clear();
        					}
        					else{
        						ref.returnEnemyObj(enemyX,enemyY).extraLives--;
        						ref.returnEnemyObj(enemyX,enemyY).currentHealth = 1;
        						
        						if(ref.returnEnemyObj(enemyX,enemyY).coward){
        							ref = playerStats.cowardMoves(ref,new PointF(enemyX,enemyY));
        						}
        						
        						if (playerStats.attacksAnger != 0){
                					ref.returnEnemyObj(enemyX,enemyY).attack *= (1 + playerStats.attacksAnger);
                				}
        						
        						ClassGraphicObject cursor = new ClassGraphicObject(tile[2]);
        						addSteps(_graphics.size()-1);
            					_graphics.clear();
        						
        						
        						if(ref.returnEnemyObj(enemyX,enemyY).banisher && !playerStats.areaAttack && !playerStats.banishImmune){
        							PointF holder = playerStats.playerMoves(ref);
        							//Log.d("dungeons - X",""+ Integer.toString((int)holder.x));
        							//Log.d("dungeons - Y",""+ Integer.toString((int) holder.y));
                					playerPosX = playerPosition.findXBoard((int) holder.x,(int) holder.y);
                					playerPosY = playerPosition.findYBoard((int) holder.x,(int) holder.y);
                					//Log.d("dungeons - X2",""+playerPosX);
                					//Log.d("dungeons - Y2",""+playerPosY);
                					cursor.getCoordinates().setX(playerPosX);
                					cursor.getCoordinates().setY(playerPosY);
                					cursorPositionX = playerPosX;
                					cursorPositionY = playerPosY;
                					checkEnemyShroudStatus();
        						}else{
        							playerPosX = secondX;
                					playerPosY = secondY;
                					cursor.getCoordinates().setX(cursorPositionX);
                					cursor.getCoordinates().setY(cursorPositionY);
                					_graphics.add(cursor);
        						}
        						
            					//addSteps(_graphics.size()-1);
            					//_graphics.clear();
            					//_graphics.add(cursor);
            					//playerPosX = secondX;
            					//playerPosY = secondY;
            					ref.mapObject.setPlayerX(playerPosition.returnXMatrix(playerPosX,playerPosY));
                				ref.mapObject.setPlayerY(playerPosition.returnYMatrix(playerPosX,playerPosY));
        					}
        				}
        				//If the enemy is still alive...
        				else{
        					sounds.playSound(9);
        					if(ref.returnEnemyObj(enemyX,enemyY).coward){
    							ref = playerStats.cowardMoves(ref,new PointF(enemyX,enemyY));
    						}
        					
        					if (playerStats.attacksAnger != 0){
            					ref.returnEnemyObj(enemyX,enemyY).attack *= (1 + playerStats.attacksAnger);
            				}
        					
        					ClassGraphicObject cursor = new ClassGraphicObject(tile[2]);
        					
        					
        					addSteps(_graphics.size()-1);
        					_graphics.clear();
        					
        					if(ref.returnEnemyObj(enemyX,enemyY).banisher && !playerStats.areaAttack && !playerStats.banishImmune){
    							PointF holder = playerStats.playerMoves(ref);
    							//Log.d("dungeons - X",""+ Integer.toString((int)holder.x));
    							//Log.d("dungeons - Y",""+ Integer.toString((int) holder.y));
    							playerPosX = playerPosition.findXBoard((int) holder.x,(int) holder.y);
            					playerPosY = playerPosition.findYBoard((int) holder.x,(int) holder.y);
            					//Log.d("dungeons - X2",""+playerPosX);
            					//Log.d("dungeons - Y2",""+playerPosY);
            					cursor.getCoordinates().setX(playerPosX);
            					cursor.getCoordinates().setY(playerPosY);
            					cursorPositionX = playerPosX;
            					cursorPositionY = playerPosY;
            					checkEnemyShroudStatus();
    						}else{
    							playerPosX = secondX;
            					playerPosY = secondY;
            					cursor.getCoordinates().setX(cursorPositionX);
            					cursor.getCoordinates().setY(cursorPositionY);
            					_graphics.add(cursor);
    						}
        					
        					//_graphics.add(cursor);
        					//playerPosX = secondX;
        					//playerPosY = secondY;
        					ref.mapObject.setPlayerX(playerPosition.returnXMatrix(playerPosX,playerPosY));
            				ref.mapObject.setPlayerY(playerPosition.returnYMatrix(playerPosX,playerPosY));
        				}
        				graphic.getCoordinates().setX(playerPosX);
    					graphic.getCoordinates().setY(playerPosY);
        				_graphics.add(graphic);
        				
        				if(!zoomer.getZoom()){
        					if (playerStats.lastPlayerAttack == 0){
        						playerStats.shroudAnimations.addDamageAnimation(playerPosX,playerPosY,0,"Missed",10,false);
        					}else if(playerStats.lastPlayerAttack > 0){
        						playerStats.shroudAnimations.addDamageAnimation(playerPosX,playerPosY,0,""+playerStats.lastPlayerAttack,10,false);
        					}
        					if (playerStats.lastEnemyAttack == 0){
        						playerStats.shroudAnimations.addDamageAnimation(cursorPositionX,cursorPositionY,1,"Dodged",10,false);
        					}else if(playerStats.lastEnemyAttack > 0){
        						playerStats.shroudAnimations.addDamageAnimation(cursorPositionX,cursorPositionY,1,""+playerStats.lastEnemyAttack,10,false);
        					}
        				}else{
        					//int animX = cursorPositionX, animY = cursorPositionY;
                			//if(zoomer.getZoom()){
                			//	int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerX()-1);
                			//	int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerY()-1);
                			//	animX = playerPositionZoomed.findXBoard(convertX, convertY);
                			//	animY = playerPositionZoomed.findYBoard(convertX, convertY);
                			//}
    						//playerStats.shroudAnimations.addKillBubbles(animX+constant/2, animY+constant/2, 0);
        					
        					
        					
                    		int pAnimX= playerPosition.returnXMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerX()-1);
                    		int pAnimY= playerPosition.returnYMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerY()-1);
                    		int playerX= playerPositionZoomed.findXBoard(pAnimX, pAnimY);
                    		int playerY= playerPositionZoomed.findYBoard(pAnimX, pAnimY);
                    		//Log.d("playerPosition.findXScreen(playerPosX,playerPosY)",""+playerPositionZoomed.findXScreen(playerPosX,playerPosY));
                    		//Log.d("playerPosition.findYScreen(playerPosX,playerPosY)",""+playerPositionZoomed.findYScreen(playerPosX,playerPosY));
                    		
                    		//Log.d("convertX",""+convertX);
                    		//Log.d("convertY",""+convertY);

                    		int EAnimX= playerPosition.returnXMatrix(playerPosition.findXScreen(cursorPositionX,cursorPositionY),playerPosition.findYScreen(cursorPositionX,cursorPositionY)) - (zoomer.returnLowerX()-1);
                    		int EAnimY= playerPosition.returnYMatrix(playerPosition.findXScreen(cursorPositionX,cursorPositionY),playerPosition.findYScreen(cursorPositionX,cursorPositionY)) - (zoomer.returnLowerY()-1);
                    		int EnemyX= playerPositionZoomed.findXBoard(EAnimX, EAnimY);
                    		int EnemyY= playerPositionZoomed.findYBoard(EAnimX, EAnimY);
                    		
        					if (playerStats.lastPlayerAttack == 0){
        						playerStats.shroudAnimations.addDamageAnimation(playerX,playerY,0,"Missed",10,false);
        					}else if(playerStats.lastPlayerAttack > 0){
        						playerStats.shroudAnimations.addDamageAnimation(playerX,playerY,0,""+playerStats.lastPlayerAttack,10,false);
        					}
        					if (playerStats.lastEnemyAttack == 0){
        						playerStats.shroudAnimations.addDamageAnimation(EnemyX,EnemyY,1,"Dodged",10,false);
        					}else if(playerStats.lastEnemyAttack > 0){
        						playerStats.shroudAnimations.addDamageAnimation(EnemyX,EnemyY,1,""+playerStats.lastEnemyAttack,10,false);
        					}
        				}
        				
        			}else{
        				if(playerPosX != cursorPositionX || playerPosY != cursorPositionY){
        					addSteps(_graphics.size()-1);
        				}
        				sounds.playSound(6);
        				playerPosX = cursorPositionX;
        				playerPosY = cursorPositionY;
        				ref.mapObject.setPlayerX(playerPosition.returnXMatrix(playerPosX,playerPosY));
        				ref.mapObject.setPlayerY(playerPosition.returnYMatrix(playerPosX,playerPosY));
        				graphic.getCoordinates().setX(cursorPositionX);
        				graphic.getCoordinates().setY(cursorPositionY);
        				_graphics.clear();
        				_graphics.add(graphic);
        			}
        		}
        	}
            }
            //If the player clicked on a wall and the position has been explored
            else if (playerPosition.onMap(playerPosition.findXScreen(boardX,boardY), playerPosition.findYScreen(boardX,boardY))
            		&& ref.shroudNum(playerPosition.returnXMatrix(playerPosition.findXScreen(boardX,boardY),playerPosition.findYScreen(boardX,boardY)), 
            				playerPosition.returnYMatrix(playerPosition.findXScreen(boardX,boardY),playerPosition.findYScreen(boardX,boardY))) == 0){
            	cursorPositionX= playerPosition.findXScreen(boardX,boardY);
            	cursorPositionY= playerPosition.findYScreen(boardX,boardY);
            	ClassGraphicObject cursor = new ClassGraphicObject(tile[2]);
            	cursor.getCoordinates().setX(cursorPositionX);
				cursor.getCoordinates().setY(cursorPositionY);
				_graphics.clear();
				_graphics.add(cursor);
				graphic.getCoordinates().setX(playerPosX);
				graphic.getCoordinates().setY(playerPosY);
				_graphics.add(graphic);
            }
        }
        
        
        public int stayInBounds(int low, int high, int number){
        	if(number >= high){
        		return high;
        	}else if(number <= low){
        		return low;
        	}
        	return number;
        }
        
        /*public boolean checkEnd(int boardX, int boardY){
        	PointF clickPoint = null;
        	boolean clickedOnMap = false;
        	if(!zoomer.getZoom()){
        		clickPoint = new PointF(boardX,boardY);
        		clickedOnMap = true;
        	}else if(playerPositionZoomed.onMap(boardX, boardY, true)){
        		int convertX, convertY;
        		convertX= (zoomer.returnLowerX()+1) + playerPositionZoomed.returnXMatrix(playerPositionZoomed.findXScreen(boardX,boardY),playerPositionZoomed.findYScreen(boardX,boardY));
        		convertY= (zoomer.returnLowerY()+1) + playerPositionZoomed.returnYMatrix(playerPositionZoomed.findXScreen(boardX,boardY),playerPositionZoomed.findYScreen(boardX,boardY));
        		clickPoint = new PointF(playerPosition.findXBoard(convertX, convertY),playerPosition.findYBoard(convertX, convertY));
        		clickedOnMap = true;
        	}
        	if(!changed && clickedOnMap){
        		cursorPositionX= playerPosition.findXScreen((int)clickPoint.x,(int)clickPoint.y);
            	cursorPositionY= playerPosition.findYScreen((int)clickPoint.x,(int)clickPoint.y);
        		int enemyX = playerPosition.returnXMatrix(cursorPositionX,cursorPositionY);
        		int enemyY = playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
        		if (ref.enemyNum(enemyX,enemyY)!=0){
        			ref.setEnemyObj(enemyX,enemyY,playerStats.calculateDamage(ref.returnEnemyObj(enemyX,enemyY), ref.exploredAround(enemyX, enemyY)));
    				
    				//If the player kills the enemy...
    				if ((ref.returnEnemyObj(enemyX,enemyY).currentHealth < 1 || ref.returnEnemyObj(enemyX,enemyY).petrified) 
    						&& (ref.returnEnemyObj(enemyX,enemyY).level == 10) &&((playerStats.player_currenthealth > 0)
    						||(playerStats.player_currenthealth <= 0 && playerStats.extraLife))){
    						return true;
    					}
    				if(playerStats.player_currenthealth <= 0 && !playerStats.extraLife){
    					return true;
    				}
        		}
        	}
        	return false;	
        }*/
        
        
        
        
        public void doClickActions(PointF eventClick){
			int eventConstant;
			
        	boardX = (int) eventClick.x;
            boardY = (int) eventClick.y;
            changed = false;

            eventConstant = (point.x/(20+1));;

            if(!zoomer.getZoom()){
            	moveWithoutZoom(boardX,boardY);
            }else if(playerPositionZoomed.onMap(boardX, boardY, true)){
            	int convertX, convertY;
            	convertX= (zoomer.returnLowerX()+1) + playerPositionZoomed.returnXMatrix(playerPositionZoomed.findXScreen(boardX,boardY),playerPositionZoomed.findYScreen(boardX,boardY));
            	convertY= (zoomer.returnLowerY()+1) + playerPositionZoomed.returnYMatrix(playerPositionZoomed.findXScreen(boardX,boardY),playerPositionZoomed.findYScreen(boardX,boardY));
            	moveWithoutZoom(playerPosition.findXBoard(convertX, convertY),playerPosition.findYBoard(convertX, convertY));
            }

            PointF cursorCoors = new PointF(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY),
            		playerPosition.returnYMatrix(cursorPositionX,cursorPositionY));
            
            PointF playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
            		playerPosition.returnYMatrix(playerPosX,playerPosY));
            
            //From here on down, the clicking will be the same as the HUD does not change
            
            //If the user clicks the potion icons
            if(
            		(boardX>(eventConstant*5)) &&
            		(boardX<(eventConstant*7)) &&
            		(boardY>(((25)* eventConstant))) &&
            		(boardY<(((27)* eventConstant)))
            		){
            	//tutorialMessages.addMessage("Using A Health Potion","You Have Used A Health Potion. " +
				//		" Remember To Use Potions Sparingly As There Are Only A limited Amount Of Them In Each Dungeon",26);
            	//testZoom();
            	if(playerStats.useHealthPotion()){
            		sounds.playSound(10);
            		playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            		playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,2,true); 
            	}
            }
            else if(
            		(boardX>(eventConstant*9)) &&
            		(boardX<(eventConstant*11)) &&
            		(boardY>(((25)* eventConstant))) &&
            		(boardY<(((27)* eventConstant)))
            		){
            	//tutorialMessages.addMessage("Using A Mana Potion","You Have Used A Mana Potion. " +
				//		" Remember To Use Potions Sparingly As There Are Only A limited Amount Of Them In Each Dungeon",27);
            	if(playerStats.useManaPotion()){
            		sounds.playSound(10);
            		playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            		playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,3,true); 
            	}
            }
            else if(
            		(boardX>(eventConstant*14)) &&
            		(boardX<(eventConstant*14)+eventConstant*1.5) &&
            		(boardY>(((20+11)* eventConstant)+eventConstant/2)) &&
            		(boardY<(((20+11)* eventConstant)+eventConstant/2)+eventConstant*1.5)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		){
            	if (playerStats.selectedSpell != 0){
            		//tutorialMessages.addMessage("You Have Selected A Spell","The Spell's Mana Cost Is In Yellow Right Under The Spell's Name. " +
            		//		"Different Spells Work When Different Objects In The Dungeon Are Selected. Be Sure To Read The Spell's Description Carefully. " +
            		//		"Tap The Spell Again To Use It. " +
            		//		"Tap The Trash Can To Destroy The Spell and Collect Benefits Depending On Your Race",5);
            		playerStats.selectedSpell = 0;
            	}else{
            		int manaHolder = playerStats.player_currentmana;
            		//use spell
            		ref = playerStats.useSpell(playerStats.currentGlyphs[playerStats.selectedSpell],ref,
            				(int)cursorCoors.x,
            				(int)cursorCoors.y
            				);
            		if((playerStats.currentGlyphs[playerStats.selectedSpell] == 16 || playerStats.currentGlyphs[playerStats.selectedSpell] == 18 || playerStats.currentGlyphs[playerStats.selectedSpell] == 5) 
            				&& playerStats.lastPlayerMagAttack != 0){
            			int animX = playerPosX, animY = playerPosY;
            			if(zoomer.getZoom()){
            				int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerX()-1);
            				int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerY()-1);
            				animX = playerPositionZoomed.findXBoard(convertX, convertY);
            				animY = playerPositionZoomed.findYBoard(convertX, convertY);
            			}
            			playerStats.shroudAnimations.addDamageAnimation(animX,animY,2,""+playerStats.lastPlayerMagAttack,10,false);
            		}
            		if(manaHolder != playerStats.player_currentmana){
            			playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            			playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,1,true); 
            		}
            		playerStats.selectedSpell = -1;
            	}
            }
            else if(
            		(boardX>(eventConstant*15.5)) &&
            		(boardX<(eventConstant*15.5)+eventConstant*1.5) &&
            		(boardY>(((20+11)* eventConstant)+eventConstant/2)) &&
            		(boardY<(((20+11)* eventConstant)+eventConstant/2)+eventConstant*1.5)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		){
            	if (playerStats.selectedSpell != 1){
            		//tutorialMessages.addMessage("You Have Selected A Spell","The Spell's Mana Cost Is In Yellow Right Under The Spell's Name. " +
            		//		"Different Spells Work When Different Objects In The Dungeon Are Selected. Be Sure To Read The Spell's Description Carefully. " +
            		//		"Tap The Spell Again To Use It. " +
            		//		"Tap The Trash Can To Destroy The Spell and Collect Benefits Depending On Your Race",5);
            		playerStats.selectedSpell = 1;
            	}else{
            		int manaHolder = playerStats.player_currentmana;
            		//use spell
            		ref = playerStats.useSpell(playerStats.currentGlyphs[playerStats.selectedSpell],ref,
            				(int)cursorCoors.x,
            				(int)cursorCoors.y
            				);
            		if((playerStats.currentGlyphs[playerStats.selectedSpell] == 16 || playerStats.currentGlyphs[playerStats.selectedSpell] == 18 || playerStats.currentGlyphs[playerStats.selectedSpell] == 5) 
            				&& playerStats.lastPlayerMagAttack != 0){
            			int animX = playerPosX, animY = playerPosY;
            			if(zoomer.getZoom()){
            				int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerX()-1);
            				int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerY()-1);
            				animX = playerPositionZoomed.findXBoard(convertX, convertY);
            				animY = playerPositionZoomed.findYBoard(convertX, convertY);
            			}
            			playerStats.shroudAnimations.addDamageAnimation(animX,animY,2,""+playerStats.lastPlayerMagAttack,10,false);
            		}
            		if(manaHolder != playerStats.player_currentmana){
            			playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            			playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,1,true); 
            		}
            		playerStats.selectedSpell = -1;
            	}
            }
            else if(
            		(boardX>(eventConstant*17)) &&
            		(boardX<(eventConstant*17)+eventConstant*1.5) &&
            		(boardY>(((20+11)* eventConstant)+eventConstant/2)) &&
            		(boardY<(((20+11)* eventConstant)+eventConstant/2)+eventConstant*1.5)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		){
            	if (playerStats.selectedSpell != 2){
            		//tutorialMessages.addMessage("You Have Selected A Spell","The Spell's Mana Cost Is In Yellow Right Under The Spell's Name. " +
            		//		"Different Spells Work When Different Objects In The Dungeon Are Selected. Be Sure To Read The Spell's Description Carefully. " +
            		//		"Tap The Spell Again To Use It. " +
            		//		"Tap The Trash Can To Destroy The Spell and Collect Benefits Depending On Your Race",5);
            		playerStats.selectedSpell = 2;
            	}else{
            		int manaHolder = playerStats.player_currentmana;
            		//use spell
            		ref = playerStats.useSpell(playerStats.currentGlyphs[playerStats.selectedSpell],ref,
            				(int)cursorCoors.x,
            				(int)cursorCoors.y
            				);
            		if((playerStats.currentGlyphs[playerStats.selectedSpell] == 16 || playerStats.currentGlyphs[playerStats.selectedSpell] == 18 || playerStats.currentGlyphs[playerStats.selectedSpell] == 5) 
            				&& playerStats.lastPlayerMagAttack != 0){
            			int animX = playerPosX, animY = playerPosY;
            			if(zoomer.getZoom()){
            				int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerX()-1);
            				int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerY()-1);
            				animX = playerPositionZoomed.findXBoard(convertX, convertY);
            				animY = playerPositionZoomed.findYBoard(convertX, convertY);
            			}
            			playerStats.shroudAnimations.addDamageAnimation(animX,animY,2,""+playerStats.lastPlayerMagAttack,10,false);
            		}
            		if(manaHolder != playerStats.player_currentmana){
            			playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            			playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,1,true); 
            		}
            		playerStats.selectedSpell = -1;
            	}
            }
            else if(
            		(boardX>(eventConstant*18.5)) &&
            		(boardX<(eventConstant*18.5)+eventConstant*1.5) &&
            		(boardY>(((20+11)* eventConstant)+eventConstant/2)) &&
            		(boardY<(((20+11)* eventConstant)+eventConstant/2)+eventConstant*1.5)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		){
            	if (playerStats.selectedSpell != 3){
            		//tutorialMessages.addMessage("You Have Selected A Spell","The Spell's Mana Cost Is In Yellow Right Under The Spell's Name. " +
            		//		"Different Spells Work When Different Objects In The Dungeon Are Selected. Be Sure To Read The Spell's Description Carefully. " +
            		//		"Tap The Spell Again To Use It. " +
            		//		"Tap The Trash Can To Destroy The Spell and Collect Benefits Depending On Your Race",5);
            		playerStats.selectedSpell = 3;
            	}else{
            		int manaHolder = playerStats.player_currentmana;
            		//use spell
            		ref = playerStats.useSpell(playerStats.currentGlyphs[playerStats.selectedSpell],ref,
            				(int)cursorCoors.x,
            				(int)cursorCoors.y
            				);
            		if((playerStats.currentGlyphs[playerStats.selectedSpell] == 16 || playerStats.currentGlyphs[playerStats.selectedSpell] == 18 || playerStats.currentGlyphs[playerStats.selectedSpell] == 5) 
            				&& playerStats.lastPlayerMagAttack != 0){
            			int animX = playerPosX, animY = playerPosY;
            			if(zoomer.getZoom()){
            				int convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerX()-1);
            				int convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(playerPosX,playerPosY),playerPosition.findYScreen(playerPosX,playerPosY)) - (zoomer.returnLowerY()-1);
            				animX = playerPositionZoomed.findXBoard(convertX, convertY);
            				animY = playerPositionZoomed.findYBoard(convertX, convertY);
            			}
            			playerStats.shroudAnimations.addDamageAnimation(animX,animY,2,""+playerStats.lastPlayerMagAttack,10,false);
            		}
            		if(manaHolder != playerStats.player_currentmana){
            			playerStats.shroudAnimations.addKillBubbles(boardX, boardY, 5,true);
            			playerStats.shroudAnimations.addRippleAnimation(boardX,boardY,1,true); 
            		}
            		playerStats.selectedSpell = -1;
            	}
            }
            else if(
            		(boardX>(eventConstant*16)) &&
            		(boardX<(eventConstant*16)+eventConstant*2) &&
            		(boardY>(((20+3)* eventConstant)+eventConstant/2)) &&
            		(boardY<(((20+3)* eventConstant)+eventConstant/2)+eventConstant*2) &&
            		(playerStats.selectedSpell != -1) &&
            		(playerStats.currentGlyphs[playerStats.selectedSpell] != 0)
            		){
            	//This is the code for when a player trashes a glyph
            	//tutorialMessages.addMessage("Trashing A Spell","You Have Chosen To Trash A Spell. Doing So Will Upgrade Your Character Based On It's Race." +
            	//		" Click The Character Icon On The Bottom Of The Screen To View What Bonuses You Receive When A Spell Is Trashed",29);
            	playerStats.currentGlyphs[playerStats.selectedSpell] = 0;
            	playerStats.selectedSpell = -1;
            	playerStats.trashGlyph();
            }
            else if (
            		//If the player wants to buy something from the store
            		(boardX>(14*eventConstant)) &&
            		(boardX<(20*eventConstant)) &&
            		(boardY>(32)* eventConstant- eventConstant/2) &&
            		(boardY<(33)* eventConstant)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) != 0)
            				&& playerStats.noStores == false
            		){
            	
            	int cost = returnTotalCost(ref.shopObj((int)cursorCoors.x, 
            			(int)cursorCoors.y).returnCost());
            	if (playerStats.player_gold >= cost && (ref.shopObj((int)cursorCoors.x, 
        				(int)cursorCoors.y).item != 13 || (ref.shopObj((int)cursorCoors.x, 
                				(int)cursorCoors.y).item == 13 && playerStats.extraLife == false))){
            		sounds.playSound(7);
            		playerStats.pietyActions(13);
            		playerStats.player_gold -= cost;
            		playerStats = ref.shopObj((int)cursorCoors.x, 
            				(int)cursorCoors.y).getEffects(playerStats);
            		ref.setShopObj((int)cursorCoors.x
            				,(int)cursorCoors.y,0,0);
            		addSteps(_graphics.size());
    				playerPosX = cursorPositionX;
    				playerPosY = cursorPositionY;
    				playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
    	            		playerPosition.returnYMatrix(playerPosX,playerPosY));
    				ref.mapObject.setPlayerX((int)playerCoors.x);
    				ref.mapObject.setPlayerY((int)playerCoors.y);
    				graphic.getCoordinates().setX(cursorPositionX);
    				graphic.getCoordinates().setY(cursorPositionY);
    				_graphics.clear();
    				_graphics.add(graphic);
            	}
            }
            else if (
            		//The player is at an altar
            		(boardX>(14*eventConstant)) &&
            		(boardX<(20*eventConstant)) &&
            		(boardY>(32)* eventConstant- eventConstant/2) &&
            		(boardY<(33)* eventConstant)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) != 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            				&& !playerStats.worshipGod
            		){
            		ref.altarObj((int)cursorCoors.x, 
            				(int)cursorCoors.y).worshipped = true;
            		
            		playerStats = ref.altarObj((int)cursorCoors.x, 
            				(int)cursorCoors.y).godsBlessing(playerStats,false);
            		
            		addSteps(_graphics.size());
    				playerPosX = cursorPositionX;
    				playerPosY = cursorPositionY;
    				playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
    	            		playerPosition.returnYMatrix(playerPosX,playerPosY));
    				ref.mapObject.setPlayerX((int)playerCoors.x);
    				ref.mapObject.setPlayerY((int)playerCoors.y);
    				graphic.getCoordinates().setX(cursorPositionX);
    				graphic.getCoordinates().setY(cursorPositionY);
    				_graphics.clear();
    				_graphics.add(graphic);
            }
            //This is for the first ritual
            else if (
            		(boardX>(15*eventConstant)+eventConstant/2) &&
            		(boardX<(27)* eventConstant) &&
            		(boardY>(20*eventConstant)+eventConstant/2) &&
            		(boardY<(29)* eventConstant - eventConstant/2)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) != 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            				&& playerStats.worshipGod
            		){
            		int ritualLevel = Draws.ritualLevels[ref.altarNum((int)cursorCoors.x, 
            				(int)cursorCoors.y)-1][0];
           
            		if (playerStats.player_piety >= ritualLevel*10){
            			playerStats = ref.altarObj((int)cursorCoors.x, 
            					(int)cursorCoors.y).godsRituals(playerStats,1);
            			playerStats.player_piety -= ritualLevel*10;
            		}
            		
            		addSteps(_graphics.size());
    				playerPosX = cursorPositionX;
    				playerPosY = cursorPositionY;
    				playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
    	            		playerPosition.returnYMatrix(playerPosX,playerPosY));
    				ref.mapObject.setPlayerX((int)playerCoors.x);
    				ref.mapObject.setPlayerY((int)playerCoors.y);
    				graphic.getCoordinates().setX(cursorPositionX);
    				graphic.getCoordinates().setY(cursorPositionY);
    				_graphics.clear();
    				_graphics.add(graphic);
            }
            //This is the second ritual
            else if (
            		(boardX>(15*eventConstant)+eventConstant/2) &&
            		(boardX<(29)* eventConstant) &&
            		(boardY>(20*eventConstant)+eventConstant/2) &&
            		(boardY<(30)* eventConstant + eventConstant/2)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) != 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            				&& playerStats.worshipGod
            		){
            		int ritualLevel = Draws.ritualLevels[ref.altarNum((int)cursorCoors.x, 
            				(int)cursorCoors.y)-1][1];
           
            		if (playerStats.player_piety >= ritualLevel*10){
            			playerStats = ref.altarObj((int)cursorCoors.x, 
            					(int)cursorCoors.y).godsRituals(playerStats,2);
            			playerStats.player_piety -= ritualLevel*10;
            		}
            		
            		addSteps(_graphics.size());
    				playerPosX = cursorPositionX;
    				playerPosY = cursorPositionY;
    				playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
    	            		playerPosition.returnYMatrix(playerPosX,playerPosY));
    				ref.mapObject.setPlayerX((int)playerCoors.x);
    				ref.mapObject.setPlayerY((int)playerCoors.y);
    				graphic.getCoordinates().setX(cursorPositionX);
    				graphic.getCoordinates().setY(cursorPositionY);
    				_graphics.clear();
    				_graphics.add(graphic);
            }
            //This is the third ritual
            else if (
            		(boardX>(15*eventConstant)+eventConstant/2) &&
            		(boardX<(31)* eventConstant) &&
            		(boardY>(20*eventConstant)+eventConstant/2) &&
            		(boardY<(33)* eventConstant - eventConstant/2)
            		&& (ref.altarNum((int)cursorCoors.x
            				,(int)cursorCoors.y) != 0)
            		&& (ref.shopNum((int)cursorCoors.x
            				,(int)cursorCoors.y) == 0)
            				&& playerStats.worshipGod
            		){
            		int ritualLevel = Draws.ritualLevels[ref.altarNum((int)cursorCoors.x, 
            				(int)cursorCoors.y)-1][2];
            		/*int playerRitualLevel = playerStats.playerTech[7];*/
           
            		if (/*playerRitualLevel >= ritualLevel &&*/ playerStats.player_piety >= ritualLevel*10){
            			playerStats = ref.altarObj((int)cursorCoors.x, 
            					(int)cursorCoors.y).godsRituals(playerStats,3);
            			playerStats.player_piety -= ritualLevel*10;
            		}
            		
            		addSteps(_graphics.size());
    				playerPosX = cursorPositionX;
    				playerPosY = cursorPositionY;
    				playerCoors = new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),
    	            		playerPosition.returnYMatrix(playerPosX,playerPosY));
    				ref.mapObject.setPlayerX((int)playerCoors.x);
    				ref.mapObject.setPlayerY((int)playerCoors.y);
    				graphic.getCoordinates().setX(cursorPositionX);
    				graphic.getCoordinates().setY(cursorPositionY);
    				_graphics.clear();
    				_graphics.add(graphic);
    				//This is for the character info screen when the player clicks on the player icon
            }else if((boardX>(2*eventConstant)+eventConstant/2) &&
            		(boardX<(5*eventConstant)+eventConstant/2) &&
            		(boardY>(23*eventConstant)) &&
            		(boardY<(26)* eventConstant)){
            	//testZoom();
            	//constant * 3
            	//canvas.drawBitmap(bitmap, (2* constant)+constant/2, ((20+3)* constant), null);
            	if(!playerStats.worshipGod){
            		tutorialMessages.showSingleMessageCharInfo(Draws.raceStrings[playerStats.player_race]  + " " +  Draws.classStrings[playerStats.player_class],
                		"Racial Bonus: \n" + Draws.raceDescriptions[playerStats.player_race] + "\n\nClass Bonus: \n" + 
                		Draws.classDescriptions[playerStats.player_class],graphic);
            	}else{
            		tutorialMessages.showSingleMessageCharInfo(Draws.raceStrings[playerStats.player_race]  + " " +  Draws.classStrings[playerStats.player_class],
                    		"Racial Bonus: \n" + Draws.raceDescriptions[playerStats.player_race] + "\n\nClass Bonus: \n" + 
                    		Draws.classDescriptions[playerStats.player_class] + 
                    				"\n\nGod: \n" + Draws.godNames[playerStats.playerGod-1] + 
                    				"\n\nTurn Ons/Offs: \n" + Draws.godDescriptions[playerStats.playerGod-1]
                    				,graphic);
            	}
            	//If the user clicks on an enemy in the info screen
            }else if((boardX>(14*eventConstant)) &&
            		(boardX<(16*eventConstant)) &&
            		(boardY>(((23)* eventConstant)+ eventConstant/2)) &&
            		(boardY<(((25)* eventConstant)+ eventConstant/2))&&
            		(ref.enemyNum(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY),
            				playerPosition.returnYMatrix(cursorPositionX,cursorPositionY)) != 0)){
            	ClassEnemyStats enemy = (ref.returnEnemyObj(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY),
        				playerPosition.returnYMatrix(cursorPositionX,cursorPositionY)));
            	System.out.println("Monster Num: "+ (enemy.returnMonster()-1));
            	int enemyNumber = enemy.returnMonster()-1;

            	switch(getEnemyPos(enemyNumber)){
            		case 0:
            			tutorialMessages.showSingleMessageCharInfo("Enemy: " + Draws.enemyStrings[enemyNumber],
                        		"Stats: \n" + compileEnemyData(enemyNumber) + "\n\nStrategy Against: \n" + 
                        				Draws.enemyStrategies[enemyNumber],enemy1);
            			break;
            		case 1:
            			tutorialMessages.showSingleMessageCharInfo("Enemy: " + Draws.enemyStrings[enemyNumber],
                        		"Stats: \n" + compileEnemyData(enemyNumber) + "\n\nStrategy Against: \n" + 
                        				Draws.enemyStrategies[enemyNumber],enemy2);
            			break;
            		case 2:
            			tutorialMessages.showSingleMessageCharInfo("Enemy: " + Draws.enemyStrings[enemyNumber],
                        		"Stats: \n" + compileEnemyData(enemyNumber) + "\n\nStrategy Against: \n" + 
                        				Draws.enemyStrategies[enemyNumber],enemy3);
            			break;
            		case 3:
            			tutorialMessages.showSingleMessageCharInfo("Enemy: " + Draws.enemyStrings[enemyNumber],
                        		"Stats: \n" + compileEnemyData(enemyNumber) + "\n\nStrategy Against: \n" + 
                        				Draws.enemyStrategies[enemyNumber],enemy4);
            			break;
            		default: tutorialMessages.showSingleMessageCharInfo("Enemy: " + Draws.enemyStrings[enemyNumber],
                    		"Stats: \n" + compileEnemyData(enemyNumber) + "\n\nStrategy Against: \n" + 
                    				Draws.enemyStrategies[enemyNumber],enemy5);
            		break;
            	}

            	
            }else if ((boardX>((12*eventConstant) + (eventConstant + eventConstant/2) - eventConstant/6)) &&
            		(boardX<((eventConstant*20) + 3*eventConstant/4)) &&
            		(boardY>(((22)* eventConstant) + eventConstant/3)) &&
            		(boardY<(((31)* eventConstant)+ 3*eventConstant/4)) &&
            		(ref.altarNum(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY),
            				playerPosition.returnYMatrix(cursorPositionX,cursorPositionY))) != 0 &&
            				!playerStats.worshipGod){
            	
            	int altar = (ref.altarNum(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY),
        				playerPosition.returnYMatrix(cursorPositionX,cursorPositionY))) - 1;
	  			
	  			tutorialMessages.showSingleMessageCharInfo("God: " + Draws.godNames[altar],
	  					Draws.godDescriptions[altar] + "\n\nBlessing: "+Draws.ritualDescriptions[altar][0] +
	  					"\nCurse: "+Draws.ritualDescriptions[altar][1] + "\n\nKnown Rituals: \n" + 
	  					compileRituals(altar));

        }else if((boardX>eventConstant/2) &&
            		(boardX<(2*eventConstant)+eventConstant/2) &&
            		(boardY>(22*eventConstant)+eventConstant/2) &&
            		(boardY<(27)* eventConstant+eventConstant/2)){
            	//constant * 3
            	//canvas.drawBitmap(bitmap, (2* constant)+constant/2, ((20+3)* constant), null);
            	tutorialMessages.showSingleMessage("Player Modifiers",
                	returnModifiers(),sendPlayerModifiers(playerStats));
            }
            
            else if(((boardX>(14*eventConstant)) &&
            		(boardX<(20*eventConstant)) &&
            		(boardY>(26*eventConstant)) &&
            		(boardY<(27*eventConstant))
            		)
            		&&(ref.enemyNum(playerPosition.returnXMatrix(cursorPositionX,cursorPositionY), playerPosition.returnYMatrix(cursorPositionX,cursorPositionY))!=0)){
            	int enemyX = playerPosition.returnXMatrix(cursorPositionX,cursorPositionY), 
            			enemyY = playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
            	//constant * 3
            	//canvas.drawBitmap(bitmap, (2* constant)+constant/2, ((20+3)* constant), null);
            	tutorialMessages.showSingleMessage("Enemy Modifiers",
                	returnModifiersEnemy(ref.returnEnemyObj(enemyX, enemyY)),sendEnemyModifiers(ref.returnEnemyObj(enemyX, enemyY)));
            }else if
            (
            		((boardX>(13.5*eventConstant)) &&
                    (boardX<(width-eventConstant)) &&
                    (boardY>(26.25*eventConstant)) &&
                    (boardY<(30.75*eventConstant))) && 
                    (ref.enemyNum((int)cursorCoors.x,(int)cursorCoors.y) == 0) &&
            		(ref.altarNum((int)cursorCoors.x,(int)cursorCoors.y) == 0) && 
            		(ref.shopNum((int)cursorCoors.x,(int)cursorCoors.y) == 0) &&
            		(ref.objNum((int)cursorCoors.x,(int)cursorCoors.y) == 0) &&
            		(ref.glyphNum((int)cursorCoors.x,(int)cursorCoors.y) == 0)
            ){
            	tutorialMessages.showSingleMessageCharInfo("Status Effects",
                		"Beneficial Effects: \n" + playerStats.returnGoodEffects() + "\n\nNegative Effects: \n" + 
                				playerStats.returnBadEffects(),graphic);
            }else{
            	playerStats.selectedSpell = -1;
            }
        //If the player beat the boss, take them to the ending screen
            //printModifiers(ref.returnEnemyObj(enemyX, enemyY), 14, 26, canvas,constant);
            //ref.returnEnemyObj(enemyX, enemyY)
            //playerPosition.returnXMatrix(cursorPositionX,cursorPositionY);
            //playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
        //This needs to be before the regen call to stop the player from gaining health after he is killed
        checkWin();
     	checkDeath();    
            
     	//tutorialMessages.addMessage("Uncovering Shroud","Uncovering The Dark Portions Of The Dungeon " +
     	//		"Will Restore Your Character's Health And Mana Based On It's Level. " +
     	//		"Enemies Will Also Regenerate Their Health When You Uncover Shroud, So Try Not To Explore In The Middle Of A Fight. " +
     	//		"Be Careful To Not Uncover Shroud Too Quickly, As You May Find Yourself Stuck",13);
     	
        playerStats = ref.updatePlayerSight(playerStats, (int)playerCoors.x, (int)playerCoors.y);
        sounds.setLocation(cursorCoors);
        checkEnemyShroudStatus();
        }
        
        public Bitmap sendPlayerModifiers(ClassGameStats playerData){
        	int count = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (playerData.playerNumber(i)){
        			count++;
        		}
        	}
        	if (count == 0){
        		count = 1;
        	}
        	
        	Bitmap bitmap = Bitmap.createBitmap(mods[0].getWidth(), mods[0].getHeight() * count, Bitmap.Config.ARGB_8888 ); 
        	//Bitmap temp;
        	Canvas canvas = new Canvas(bitmap);
        	int movement = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (playerData.playerNumber(i)){
        			//temp = mods[i];
                	//temp = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), 
                	//		mod1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),scale,false), true);
        			canvas.drawBitmap(mods[i], 0f, movement, null);
        			movement+=mods[i].getHeight();
        		}
        	}
        	return bitmap;
        }
        
        public Bitmap sendEnemyModifiers(ClassEnemyStats enemy){
        	int count = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (enemy.modNumber(i)){
        			count++;
        		}
        	}
        	if (count == 0){
        		count = 1;
        	}
        	
        	Bitmap bitmap = Bitmap.createBitmap(mods[0].getWidth(), mods[0].getHeight() * count, Bitmap.Config.ARGB_8888 ); 
        	//Bitmap temp;
        	Canvas canvas = new Canvas(bitmap);
        	int movement = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (enemy.modNumber(i)){
        			//temp = mods[i];
                	//temp = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), 
                	//		mod1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),scale,false), true);
        			canvas.drawBitmap(mods[i], 0f, movement, null);
        			movement+=mods[i].getHeight();
        		}
        	}
        	return bitmap;
        }
        
        
        //This is only for the player info when the player is clicked
        public String returnBenefits(){
        	String holder = "\n\nBenefits:\n";
        	/*if(playerStats.extraLife){
        		holder += "Extra Life\n";
        	}
        	if(playerStats.firstStrike()){
        		holder += "First Strike\n";
        	}*/
        	
        	/*String holder = "\n\nStats:\n";
        	int predictedAttack = playerStats.playerStrike(new enemyStats(0,0,0,0, false, false, 
            		false, false, false, false, false, false, false, false,false, false, false, 
            		false,false),true);
        	
        	holder += "Phys Atk: " + (int)((float) predictedAttack/ (float)playerStats.player_attack)*100 + "%\n";
        	holder += "Phys Atk: " + playerStats.player_attack + "%\n";
        	holder += "Phys Atk: " + predictedAttack + "%\n";
        	holder += "Magic Atk: " + (int)playerStats.returnMagicStats() + "%\n";
        	holder += "Phys Resist: " + (int)playerStats.physicalResistance*100 + "%\n";
        	holder += "Magic Resist: " + (int)playerStats.magicalResistance*100 + "%\n";
        	
        	holder += "\n\nModifiers:\n";
        	if(playerStats.extraLife){
        		holder += "Extra Life\n";
        	}
        	if(playerStats.firstStrike()){
        		holder += "First Strike\n";
        	}*/
        	
        	return holder;
        }
        
        public String returnModifiersEnemy(ClassEnemyStats enemy){
        	String holder = "\n";
        	for(int i = 0; i<mods.length;i++){
        		if (enemy.modNumber(i)){
        			switch(i){
        			case 0:holder +="ManaBurn: No Shroud Mana Regen\n";break;
        			case 1:holder +="Poisoned: No Shroud Health Regen\n";break;
        			case 2:holder +="+25% Magic Resistance\n";break;
        			case 3:holder +="+50% Magic Resistance\n";break;
        			case 4:holder +="+25% Physical Resistance\n";break;
        			case 5:holder +="+50% Physical Resistance\n";break;
        			case 6:holder +="Amnesia: -25% MagAtk\n";break;
        			case 7:holder +="Blind: 10% MissChance\n";break;
        			case 8:holder +="Weakness: -25% PhysAtk\n";break;
        			case 9:holder +="Poisoned Enemy\n";break;
        			case 10:holder +="Magic Attack\n";break;
        			case 11:holder +="Undead\n";break;
        			case 12:holder +="Extra Life: Player Revived Upon Death\n";break;
        			case 13:holder +="First Strike: Character Attacks First\n";break;
        			case 14:holder +="Coward: Enemy Runs When Attacked\n";break;
        			case 15:holder +="Banish: Player Teleported After Attack\n";break;
        			case 16:holder +="Static: Player's HUD Disappears\n";break;
        			default: break;
        			}
        		}
        	}

			return holder;
        }
        
      //This is only for the player info when the player is clicked
        public String returnModifiers(){
        	String holder = "\n";
        	for(int i = 0; i<mods.length;i++){
        		if (playerStats.playerNumber(i)){
        			switch(i){
        			case 0:holder +="ManaBurn: No Shroud Mana Regen\n";break;
        			case 1:holder +="Poisoned: No Shroud Health Regen\n";break;
        			case 2:holder +="+25% Magic Resistance\n";break;
        			case 3:holder +="+50% Magic Resistance\n";break;
        			case 4:holder +="+25% Physical Resistance\n";break;
        			case 5:holder +="+50% Physical Resistance\n";break;
        			case 6:holder +="Amnesia: -25% MagAtk\n";break;
        			case 7:holder +="Blind: 10% MissChance\n";break;
        			case 8:holder +="Weakness: -25% PhysAtk\n";break;
        			case 9:holder +="Poisoned Enemy\n";break;
        			case 10:holder +="Magic Attack\n";break;
        			case 11:holder +="Undead\n";break;
        			case 12:holder +="Extra Life: Player Revived Upon Death\n";break;
        			case 13:holder +="First Strike: Player Attacks First\n";break;
        			case 14:holder +="Coward: Enemy Runs When Attacked\n";break;
        			case 15:holder +="Banish: Player Teleported After Attack\n";break;
        			case 16:holder +="Static: Player's HUD Disappears\n";break;
        			default: break;
        			}
        		}
        	}

			return holder;
        }
        
        @Override
        public boolean onTouchEvent(final MotionEvent event) {

        	doTask(event);
 
        	if(_thread.getGameStatus() && _thread.getEndStatus()){
        		//This is so that the function cannot be called twice if 
        		//there are two or more threads active at the same time
        		//_thread.endDrawn = false;
        		//_thread.gameOver = false;
        		boolean retry = true;
            	_thread.setRunning(false);
            	while (retry) {
            		try {
            			_thread.join();
            			retry = false;
            			//System.out.println("All Threads Destroyed!!!");
            		} catch (InterruptedException e) {
            			System.out.println(e);
            			// we will try it again and again...
            		}
            	}
				levelOver();
        	}
        	return true;
        }
        
        public boolean doTask(MotionEvent event){
        	
        	int action = event.getAction();
        	int actionCode = action & MotionEvent.ACTION_MASK;
            //synchronized (scale) {
				if ((actionCode == MotionEvent.ACTION_POINTER_DOWN)) {
					eventWatcher.switchZoomed();
            	}
                if ((actionCode == MotionEvent.ACTION_DOWN)) {
                	pLocation = new PointF(event.getX()-pMargins.x, event.getY()-pMargins.y);
                	eventWatcher.setClick(event.getX(), event.getY());
                	eventWatcher.switchClicked();
                }
                /*if ((actionCode == MotionEvent.ACTION_MOVE)) {
                	PointF pMove = new PointF(event.getX(), event.getY());
                	
                	pMargins.x = (pMove.x-pLocation.x);
                	pMargins.y = (pMove.y-pLocation.y);    	
                	
                	if (pMargins.x> 0){pMargins.x = 0;}
                	if (pMargins.y> 0){pMargins.y = 0;}
                	if (pMargins.x<(-numTiles*scale) + display.getWidth()){pMargins.x=(-numTiles*scale) + display.getWidth();}
                	if (pMargins.y<(-numTiles*scale) + display.getHeight()){pMargins.y=(-numTiles*scale) + display.getHeight();}
                	
                }*/
                return true;
          //}
        }
        
        public void checkWin(){
            if (playerStats.checkBoss){
            	if(ref.allBossesDead()){
            		_thread.gameDone();
            	}else{
            		playerStats.checkBoss = false;
            	}
            }
        }
        
        public void DeathWinMessages(){
        	if (playerStats.checkBoss){
        		boolean bossesDead = ref.allBossesDead();
            	if(bossesDead && playerStats.player_level == 0){
            		//tutorialMessages.addMessage("You Have Won","You Have Beaten The Tutorial Level! " +
            		//		"Try Beating Each Level With Each Class To Unlock Everything. To" +
            		//		" See The Upgrades That You Have Unlocked Throughout The Game, Tap The Player Info Button On The Main Menu",11);
            		while(tutorialMessages.getSize()>0 && playerStats.player_level == 0){
            			tutorialMessages.showMessages(false);
            		}
            	}else if(bossesDead){
            		//tutorialMessages._headingHolder.clear();
            		//tutorialMessages._messageHolder.clear();
            		//tutorialMessages.addMessage("Level Completed","As the final monster writhes in agony at your feet, you let out a shout" +
            		//		" and pick up the treasure laying at its feet, knowing that you have grown stronger in the process",30);
            		//while(tutorialMessages._messageHolder.size()>0 && playerStats.player_level != 0){
            		//tutorialMessages.showMessages(true);
            		//}
            	}
            }
        	if(playerStats.player_currenthealth < 1){
            	if(!playerStats.extraLife && playerStats.player_level == 0){
            		//tutorialMessages.addMessage("You Just Died","In The Future You Should Avoid Doing This",12);
            		while(tutorialMessages.getSize()>0 && playerStats.player_level == 0){
            		tutorialMessages.showMessages(false);
            		}
                }else if(!playerStats.extraLife && playerStats.player_level != 0){
                	//tutorialMessages._headingHolder.clear();
            		//tutorialMessages._messageHolder.clear();
                	//tutorialMessages.addMessage("Death","The demons of this dungeon laugh at your pathetic attempt to thwart their evil plans." +
                	//		" You stumble towards a birght light and escape the dungeon before death comes for you",31);
            		//while(tutorialMessages._messageHolder.size()>0 && playerStats.player_level != 0){
            		//	tutorialMessages.showMessages(true);
            		//}
                }
                else{
                	//tutorialMessages.addMessage("You Have Been Resurrected","Sometimes Dying Can Be Advantageous When Facing Stronger Foes." +
                	//		" Try To Come Up With A Strategy That Works For You",28);
                	while(tutorialMessages.getSize()>0 && playerStats.player_level == 0){
                	tutorialMessages.showMessages(false);
                	}
                	}
			}
        }
        
        public void checkDeath(){
        	if(playerStats.player_currenthealth < 1){
            	if(!playerStats.extraLife){
            		_thread.gameDone();
                }
                else{
                	playerStats.playerDied = true;
                	playerStats.extraLife = false;
                	playerStats.pietyActions(6);
                	playerStats.player_currenthealth = 1;
                	playerStats.player_health += playerStats.deathHealthBonus;
                	}
			}
        }
        
        public void checkEnemyShroudStatus(){
        	if (playerStats.enemySightBonus!=0||playerStats.enemySightBonusHealth!=0){
            	if (playerStats.enemySightBonus!=0){
            		playerStats.totalSightBonus = ref.computeSightBonus(playerStats.enemySightBonus);
            	}else{
            		playerStats.totalSightBonusHealth = ref.computeSightBonus(playerStats.enemySightBonusHealth);
            		if (playerStats.player_currenthealth > playerStats.getPlayerMaxHealth()){
            			playerStats.player_currenthealth = playerStats.getPlayerMaxHealth();
            		}
            	}
			}
        	if (playerStats.player_level == 0){
				if(ref.computeSightBonus(1)>0){
					//tutorialMessages.addMessage("Found Enemy","You Have Spotted An Enemy. " +
					//		"The Predicted Outcome Of Your Actions Is Displayed On The Bottom Right Hand Side Of The Screen When An Enemy Is Selected." +
					//		" Attack The Enemy By Clicking On Him Twice. ",2);

				}
			}
        }
        
        public void levelOver(){
        	//I don't know if this fixes the problem, but I think that multiple threads may have been causing
        	//an error with the OnActivityResult function in the Dungeons activity
        	//synchronized(_thread){
        	setContentView(R.layout.loadingscreen);
        	if(backgroundMusic.running){
      			backgroundMusic.stopBackground();
      		}
        	
        	//Intent intent = new Intent(getBaseContext(), myMediaPlayer.class);
        	//System.out.println(path);
        	//intent.putExtra("PATH_ID", playerStats);
        	//startActivity(intent);
        	//passedPlayerStats = playerStats;
        	//Intent i = new Intent(getBaseContext(), Dungeons.class);
    		//startActivity(i);
        	//Dungeons.passedPlayerStats = playerStats;
        	//Log.d("WinBug","Before Save");
        	
        	//Intent resultIntent = getIntent();
        	//Bundle b = new Bundle();
        	ClassResultHolder results = new ClassResultHolder(playerStats);
        	
        	database.insertTempDatabase(results.player_race, results.player_class, 
        			results.player_level, results.player_rank, results.calculateScore * results.endingMultiplier, 
        			results.stepsTaken, results.checkBoss? 1 : 0);
        	
        	/*resultIntent.putExtra("CheckBoss", results.checkBoss);
        	resultIntent.putExtra("playerLeft", results.playerLeft);
        	resultIntent.putExtra("playerRight", results.playerRight);
        	resultIntent.putExtra("playerBottom", results.playerBottom);
        	resultIntent.putExtra("player_race", results.player_race);
        	resultIntent.putExtra("player_class", results.player_class);
        	resultIntent.putExtra("player_level", results.player_level);
        	resultIntent.putExtra("playerID", results.playerID);
        	resultIntent.putExtra("player_gold", results.player_gold);
        	resultIntent.putExtra("endingMultiplier", results.endingMultiplier);
        	resultIntent.putExtra("calculateScore", results.calculateScore);
        	resultIntent.putExtra("player_rank", results.player_rank);
        	resultIntent.putExtra("stepsTaken", results.stepsTaken);
        	resultIntent.putExtra("rankTitle", results.rankTitle);
        	resultIntent.putExtra("bkVolume", backgroundMusic.getVolume());
        	resultIntent.putExtra("sfxVolume", sounds.getVolume());*/
        	//Log.d("WinBug","During Save");
        	//results.printInfo();
   		 	//b.putSerializable("bundleobj", results);
   		 	//resultIntent.putExtras(b);
        	// TODO Add extras or a data URI to this intent as appropriate.
        	//resultIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT );
        	//setResult(Activity.RESULT_OK, resultIntent);
        	//Log.d("WinBug","After Save");
        	//System.out.println(getIntent().describeContents());
	    	//System.out.println(getIntent().toString());
        	finish();
        	//}
        	//Dungeons.infoMenu(playerStats);
        }

		public int getEnemyPos(int enemy){
        	for(int i =0;i<Draws.levelMonsters[playerStats.player_level].length; i++){
        		if (Draws.levelMonsters[playerStats.player_level][i] == enemy){
        			return i;
        		}
        	}
        	//This happens when a grumpkin is summoned
        	return 4;
        }
		
		public void checkForMessages(PointF player){
			int message = Draws.tutorialMessageMap[(int) player.y][(int) player.x];
			if(message!=0){
				synchronized(tutorialMessages){
					tutorialMessages.addMessage(Draws.tutorialMessageTitles[message-1],Draws.tutorialMessages[message-1],message);
				}
			}
		}
		
		public void drawStuff(Canvas canvas){
			if(canvas!=null){
			Paint myPaint = new Paint();
        	Bitmap bitmap;
        	ClassGraphicObject.Coordinates coords;
        	int cursorX = playerPosition.returnXMatrix(cursorPositionX,cursorPositionY);
        	int cursorY = playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
        	if(playerStats.player_level == 0){
        		checkForMessages(new PointF(playerPosition.returnXMatrix(playerPosX,playerPosY),playerPosition.returnYMatrix(playerPosX,playerPosY)));
        	}
        	//GraphicObject gameIcon;
        	//if(leftHome){
            canvas.drawColor(Color.BLACK);
            //GraphicObject floor = new GraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.dirt_crypt));
            //GraphicObject wall = new GraphicObject(BitmapFactory.decodeResource(getResources(), R.drawable.wall_crypt));
            
            if (_graphics.isEmpty()){
            	graphic.getCoordinates().setX(ref.returnPlayerStartX());
                graphic.getCoordinates().setY(ref.returnPlayerStartY());
                _graphics.add(graphic);
            }
            int lastX = 0;
            int lastY =0;
            int rotation = 0;
            Matrix tempMatrix;
            playerStats.updateTotemBonus(ref.returnTotems());
            //if (!zoomer.zoomed){
            int eventConstant = constant;
            if(zoomer.getZoom()){
            	eventConstant = (point.x/(20+1))*2;
            }
            
            zoomer.setPlayerPos(playerPosition.returnXMatrix(playerPosX,playerPosY),playerPosition.returnYMatrix(playerPosX,playerPosY));
            
            for(int lowY = zoomer.returnLowerY(),y=0;lowY<zoomer.returnUpperY();y++,lowY++){
            	for(int lowX =zoomer.returnLowerX(),x=0;lowX<zoomer.returnUpperX();x++,lowX++){
            		//System.out.println("Matrix: " + lowX + ":" + lowY);
            		bitmap = tile[levelMap[lowX][lowY]];
            		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		if (ref.debrisNum(lowX,lowY) != 0){
            			//7 means half shroud
            			//8 means full shroud
            			bitmap = debris[ref.debrisNum(lowX,lowY)-1];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.shopNum(lowX, lowY)!=0){
            			bitmap = location[0];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.altarNum(lowX, lowY)!=0 && ref.altarObj(lowX, lowY).worshipped == false){
            			bitmap = location[1];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.altarNum(lowX, lowY)!=0 && ref.altarObj(lowX, lowY).worshipped == true){
            			bitmap = location[2];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.glyphNum(lowX,lowY) != 0){
            			bitmap = glyphs[(ref.glyphNum(lowX,lowY)-1)];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.objNum(lowX,lowY) != 0){
            			bitmap = objects[(ref.objNum(lowX,lowY)-1)];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if (ref.enemyNum(lowX,lowY) != 0){
            			bitmap = enemies[getEnemyPos(ref.enemyNum(lowX,lowY)-1)];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
                		
                		if (!zoomer.getZoom()){
                			if(cursorX==x && cursorY==y){
                				myPaint.setTextSize(textScaler + 12);
                			}else{
                				myPaint.setTextSize(textScaler + 7);
                			}
                		}
                		else{
                			if(cursorX==lowX && cursorY==lowY){
                				myPaint.setTextSize(textScaler + 24);
                			}else{
                				myPaint.setTextSize(textScaler + 18);
                			}
                		}
                		
                		myPaint.setTextAlign(Paint.Align.CENTER);
                		myPaint.setStrokeWidth(3);
                		myPaint.setStyle(Paint.Style.FILL);
                		myPaint.setTypeface(Typeface.DEFAULT_BOLD);
                		myPaint.setColor(Color.BLACK);
                		if(!playerStats.sHub){
                		canvas.drawText(String.valueOf(ref.returnEnemyObj(lowX, lowY).level), zoomer.adjustZoomBoundries(x,eventConstant,width)+zoomer.zoomedX()-1, zoomer.adjustZoomBoundriesText(y,eventConstant,width)-2, myPaint);
                		canvas.drawText(String.valueOf(ref.returnEnemyObj(lowX, lowY).level), zoomer.adjustZoomBoundries(x,eventConstant,width)+zoomer.zoomedX()+1, zoomer.adjustZoomBoundriesText(y,eventConstant,width)-2, myPaint);
                		canvas.drawText(String.valueOf(ref.returnEnemyObj(lowX, lowY).level), zoomer.adjustZoomBoundries(x,eventConstant,width)+zoomer.zoomedX()-1, zoomer.adjustZoomBoundriesText(y,eventConstant,width)-4, myPaint);
                		canvas.drawText(String.valueOf(ref.returnEnemyObj(lowX, lowY).level), zoomer.adjustZoomBoundries(x,eventConstant,width)+zoomer.zoomedX()+1, zoomer.adjustZoomBoundriesText(y,eventConstant,width)-4, myPaint);
                		
                		if (ref.returnEnemyObj(lowX, lowY).level<4){
                        	myPaint.setColor(Color.GREEN);
                        }else if (ref.returnEnemyObj(lowX, lowY).level<8){
                        	myPaint.setColor(Color.YELLOW);
                        }else{
                        	myPaint.setColor(Color.RED);
                        }
                		
                		myPaint.setStrokeWidth(1);
                		
                		
                		canvas.drawText(String.valueOf(ref.returnEnemyObj(lowX, lowY).level), zoomer.adjustZoomBoundries(x,eventConstant,width)+zoomer.zoomedX(), zoomer.adjustZoomBoundriesText(y,eventConstant,width)-3, myPaint);
                		}
                		//This way uses pictures instead of text. Figured out that text looked better
                		/*if(cursorX==x && cursorY==y){
                    		bitmap = numbers[ref.returnEnemyObj(x, y).level-1];
                    		bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), num1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (scale*.75)), true);
                    		canvas.drawBitmap(bitmap, (x*constant)+constant, (y*constant)+ constant+constant/4, null);
                		}else{
                			bitmap = numbers[ref.returnEnemyObj(x, y).level-1];
                    		bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), num1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (scale*.5)), true);
                    		canvas.drawBitmap(bitmap, (x*constant)+constant, (y*constant)+ constant+constant/2, null);
                		}*/

                		myPaint.setTypeface(Typeface.DEFAULT);

            		}
            		if (ref.shroudNum(lowX,lowY) != 0){
            			//7 means half shroud
            			//8 means full shroud
            			bitmap = tile[ref.shroudNum(lowX,lowY)+6];
                		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if ((ref.shroudNum(lowX,lowY) != 0) && playerStats.seeMonsters && (ref.enemyNum(lowX,lowY) != 0) && (ref.returnEnemyObj(lowX, lowY).level <= playerStats.player_rank)){
            			bitmap = haze[0];
            			canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if ((ref.shroudNum(lowX,lowY) != 0) && playerStats.seeItems && (ref.objNum(lowX,lowY) != 0)){
            			bitmap = haze[1];
            			canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if ((ref.shroudNum(lowX,lowY) != 0) && playerStats.seeGlyphs && (ref.glyphNum(lowX,lowY) != 0)){
            			bitmap = haze[2];
            			canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		if ((ref.shroudNum(lowX,lowY) != 0) && playerStats.seeAltars && (ref.altarNum(lowX,lowY) != 0)){
            			bitmap = location[3];
            			canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(x,eventConstant,width), zoomer.adjustZoomBoundries(y,eventConstant,width), null);
            		}
            		//if (ref.shopNum(x, y)!=0){
            		//	bitmap = location[0];
                	//	canvas.drawBitmap(bitmap, (x*constant)+constant, (y*constant)+ constant, null);
            		//}
            		//if (ref.altarNum(x, y)!=0){
            		//	bitmap = location[1];
                	//	canvas.drawBitmap(bitmap, (x*constant)+constant, (y*constant)+ constant, null);
            		//}
            	}
            }
            int playerConstant;
            if(zoomer.getZoom()){
            	playerConstant = eventConstant;
            }else{
            	playerConstant = scale;
            }

            for (ClassGraphicObject graphicMoves : _graphics) {
                //This if for rotating the footprints
            	if (graphicMoves == graphic){
                 	coords = graphicMoves.getCoordinates();
                   	int Xposition = zoomer.translateX(playerPosition.returnXMatrix(coords.getX(), coords.getY()),playerPosition.returnYMatrix(coords.getX(), coords.getY()));
                   	int Yposition = zoomer.translateY(playerPosition.returnXMatrix(coords.getX(), coords.getY()),playerPosition.returnYMatrix(coords.getX(), coords.getY()));
                	int compareX = zoomer.translateX(playerPosition.returnXMatrix(cursorPositionX, cursorPositionY),playerPosition.returnYMatrix(cursorPositionX, cursorPositionY));
                	int compareY = zoomer.translateY(playerPosition.returnXMatrix(cursorPositionX, cursorPositionY),playerPosition.returnYMatrix(cursorPositionX, cursorPositionY));
                   	if (Xposition != -1 && Yposition != -1){
                   		lastX = Xposition;
                   		lastY = Yposition;
                   		bitmap = graphicMoves.getGraphic();
                   		bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphicMoves.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),playerConstant,false), true);
                   		if(!playerAttacking){
                   			canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width), zoomer.adjustZoomBoundries(lastY,eventConstant,width), null);
                   		}else{
                   			//System.out.println("Cursor: " + cursorX + " : " + cursorY);
                   			//System.out.println("Position: " + Xposition + " : " + Yposition);
                   			if(compareX>Xposition){canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width)+5, zoomer.adjustZoomBoundries(lastY,eventConstant,width), null);}
                   			else if(compareX<Xposition){canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width)-5, zoomer.adjustZoomBoundries(lastY,eventConstant,width), null);}
                   			else if(compareY>Yposition){canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width), zoomer.adjustZoomBoundries(lastY,eventConstant,width)+5, null);}
                   			else if(compareY<Yposition){canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width), zoomer.adjustZoomBoundries(lastY,eventConstant,width)-5, null);}
                   			playerAttacking = !playerAttacking;
                   		}
                   		
                   	}
               	}else{
               		coords = graphicMoves.getCoordinates();
               		int Xposition = zoomer.translateX(playerPosition.returnXMatrix(coords.getX(), coords.getY()),playerPosition.returnYMatrix(coords.getX(), coords.getY()));
                   	int Yposition = zoomer.translateY(playerPosition.returnXMatrix(coords.getX(), coords.getY()),playerPosition.returnYMatrix(coords.getX(), coords.getY()));
                   	rotation = figureRotation(Xposition, Yposition, lastX, lastY);
                   	if (Xposition != -1 && Yposition != -1){
                   		lastX = Xposition;
                   		lastY = Yposition;
                   		bitmap = graphicMoves.getGraphic();
                   		tempMatrix = graphicMoves.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),playerConstant,false);
                   		tempMatrix.postRotate(rotation);
                   		bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), tempMatrix, true);
                   		canvas.drawBitmap(bitmap, zoomer.adjustZoomBoundries(lastX,eventConstant,width), zoomer.adjustZoomBoundries(lastY,eventConstant,width), null);
               		}
               	}
            }

            int playerX = playerPosition.returnXMatrix(playerPosX, playerPosY), 
            		playerY = playerPosition.returnYMatrix(playerPosX, playerPosY);
            //This draws the player info bar on the bottom of the screen
            //This is a quick fix. If the tiles change, the hud at the bottom will also shrink
            //This is not what I want to happen
            
            int animX = playerPosX, animY = playerPosY;
            int convertX, convertY;
			if(zoomer.getZoom()){
				convertX= playerPosition.returnXMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerX()-1);
				convertY= playerPosition.returnYMatrix(playerPosition.findXScreen(animX,animY),playerPosition.findYScreen(animX,animY)) - (zoomer.returnLowerY()-1);
				//System.out.println(convertX + ":" + convertY);
				animX = playerPositionZoomed.findXBoard(convertX, convertY);
				animY = playerPositionZoomed.findYBoard(convertX, convertY);
			}
            
            //Checks to make sure that the player has not stepped on any items
            if(ref.objNum(playerX,playerY) != 0){
            	playerStats.pietyActions(14);
            	//If they have, add the item to their stats
            	switch(ref.objNum(playerX,playerY)){
            		case 1: playerStats.player_attack+=(playerStats.addToAttackItem + 1); playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,0); 
            		//tutorialMessages.addMessage("Attack Upgrade","This Will Increase Your Attack By 1",14);
            		sounds.playSound(8);
            		break;
            		case 2: playerStats.player_gold+=10 + playerStats.goldBonus; 
            		playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,1); 
            		playerStats.shroudAnimations.addDamageAnimation(animX+eventConstant/2,animY+eventConstant/2,3,"+"+(10 + playerStats.goldBonus),10,false);
            		//tutorialMessages.addMessage("Gold Pile","Use Gold For Buying Items, Spells, and Special Attacks",15);
            		sounds.playSound(7);
            		break;
            		case 3: playerStats.player_hpotions += 1 + playerStats.hPotionBonus; 
            		playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,2); 
            		//tutorialMessages.addMessage("Health Potion","Tap The Health Potion Icon Below To Use It. " +
            		//		"Restores 40% Total HP To Most Characters. This Can Be Upgraded Later On",16);
            		sounds.playSound(11);
            		break;
            		case 4: playerStats.player_health+=5; playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,2); 
            		//tutorialMessages.addMessage("Health Upgrade","This Will Increase Your Health By 5",17);
            		sounds.playSound(8);
            		break;
            		case 5: 
            		if(!playerStats.hitIncreaseAttack){
            			playerStats.player_mpotions += 1 + playerStats.mPotionBonus; 
            		}else{
            			playerStats.player_hpotions += 1 + playerStats.hPotionBonus; 
            		}
            		playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,3); 
            		//tutorialMessages.addMessage("Mana Potion","Tap The Mana Potion Icon Below To Use It. " +
            		//		"Restores 40% Total MP To Most Characters. This Can Be Upgraded Later On",18);
            		sounds.playSound(11);
            		break;
            		case 6: playerStats.player_health-=playerStats.addToManaItem; playerStats.player_mana+=5+playerStats.addToManaItem; playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,3); 
            		//tutorialMessages.addMessage("Mana Upgrade","This Will Increase Your Mana By 5",19);
            		sounds.playSound(8);
            		break;
            		default: break;
            	}
            	ref.setObjNum(playerX,playerY,0);
            }
            
            if(ref.debrisNum(playerX,playerY) == 1){
            	//tutorialMessages.addMessage("Blood Pool","Certain Characters, Gods, and Spells Can Use This For Certain Bonusses. " +
            	//		"\n\nFor Example: The Grumpkin Spell Can Turn These Pools Into Enemies For Extra Experience",20);
            	boolean absorb = false;
            	if((playerStats.bloodSucker != 0) && (playerStats.player_currenthealth < playerStats.getPlayerMaxHealth())){
            		ref.setDebrisObj(playerX,playerY,0);
            		playerStats.shroudAnimations.addAnimatedShroud(animX+eventConstant/2, animY+eventConstant/2, 1);
            		playerStats.player_currenthealth += playerStats.getPlayerMaxHealth() * playerStats.bloodSucker;
            		if(!absorb){
            			playerStats.pietyActions(16);
            			absorb = true;
            		}
            		if (playerStats.player_currenthealth > playerStats.getPlayerMaxHealth()){
            			playerStats.player_currenthealth = playerStats.getPlayerMaxHealth();
            		}
            	}
            	if (playerStats.bloodManaBurn){
            		if(!absorb){
            			playerStats.pietyActions(16);
            			absorb = true;
            		}
            		playerStats.shroudAnimations.addKillBubbles(animX+eventConstant/2, animY+eventConstant/2, 1);
            		playerStats.manaBurn = true;
            		ref.setDebrisObj(playerX,playerY,0);
            	}
            	if (playerStats.lichAbsorb){
            		if(!absorb){
            			playerStats.pietyActions(16);
            			absorb = true;
            		}
            		Random random = new Random(System.currentTimeMillis());
            		int chance = (random.nextInt( 3 ));
            		//Increase lich stat by 1 or 2 points every level. 1 or 2 every time is unbalanced
            		int increase = (random.nextInt( 2 ))+1;
            		switch(chance){
            			case 0:playerStats.xtraMana += increase; playerStats.shroudAnimations.addKillBubbles(animX+eventConstant/2, animY+eventConstant/2, 3); break;
            			case 1:playerStats.xtraStrength += increase; playerStats.shroudAnimations.addKillBubbles(animX+eventConstant/2, animY+eventConstant/2, 0);break;
            			case 2:playerStats.sickly -= increase; playerStats.shroudAnimations.addKillBubbles(animX+eventConstant/2, animY+eventConstant/2, 2);break;
            			default:playerStats.sickly -= increase; playerStats.shroudAnimations.addKillBubbles(animX+eventConstant/2, animY+eventConstant/2, 2);break;
            		}
            		ref.setDebrisObj(playerX,playerY,0);
            	}
            	if(playerStats.bloodCollector && !playerStats.extraLife){
            		playerStats.bloodCollected++;
            		if(playerStats.bloodCollected>=5){
            			playerStats.extraLife = true;
            			playerStats.bloodCollected=0;
            		}
            		if(!absorb){
            			playerStats.pietyActions(16);
            			absorb = true;
            		}
            		ref.setDebrisObj(playerX,playerY,0);
            	}
            	if(playerStats.isKing){
            		if(!absorb){
            			playerStats.pietyActions(16);
            			absorb = true;
            		}
            		playerStats.shroudAnimations.addRippleAnimation(animX+eventConstant/2,animY+eventConstant/2,1); 
            		playerStats.shroudAnimations.addDamageAnimation(animX+eventConstant/2,animY+eventConstant/2,3,"+4",10,false);
            		playerStats.player_gold += 4;
            		ref.setDebrisObj(playerX,playerY,0);
            	}
            }
            
            if(ref.glyphNum(playerX,playerY) != 0){
            	if (!sounds.returnLastPlayedLocationSame()){
            		sounds.playSound(16);
            	}
            	//tutorialMessages.addMessage("Picked Up A Spell","The Tap It In The Bottom Right Hand Corner To Use It",21);
            	//If they have stepped on glyph, add the glyph
            	for(int i = 0; i < playerStats.currentGlyphs.length; i++){
            		//Find an empty spot if there is one
            		if (playerStats.currentGlyphs[i] == 0){
            			//If there is one, break out of the loop and add the spell to the player's inventory
            			playerStats.currentGlyphs[i] = ref.glyphNum(playerX,playerY);
            			ref.setGlyphNum(playerX,playerY,0);
            			break;
            		}
            	}
            }
            drawHUD(canvas, point.x/(21));
        	DeathWinMessages();
			}
		}
		
		public void drawLoading(Canvas canvas){
			Paint myPaint = new Paint();
			canvas.drawColor(Color.BLACK);
			myPaint.setColor(Color.YELLOW);
        	myPaint.setTextSize(textScaler + 24);
        	String sentence = "Tap Anywhere To Continue";
			float sentenceWidth = myPaint.measureText(sentence);
			float startPositionX = (width - sentenceWidth) / 2;
			canvas.drawText("Tap Anywhere To Continue",startPositionX, (4*height)/5, myPaint);
		}
		
		public void drawGameOver(Canvas canvas){
			Paint myPaint = new Paint();
			canvas.drawColor(Color.BLACK);
			//So I don't quite know why this works, but this needs to be here

			if(playerStats.shroudAnimations.moveDown.size()==0 && !_thread.animationMade){
				if(playerStats.checkBoss){
					playerStats.shroudAnimations.addmoveDown(0,height/7, 1); 
					_thread.animationMade = true;
				}else{
					playerStats.shroudAnimations.addmoveDown(0,height/7, 0); 
					_thread.animationMade = true;
				}
			}
			
            if(playerStats.shroudAnimations.moveDown.size()>0){
            	myPaint.setStyle(Paint.Style.FILL); 
            	playerStats.shroudAnimations.moveDownAnimation();
            	for (int i = 0; i < playerStats.shroudAnimations.moveDown.size();i++){
            		int Y = playerStats.shroudAnimations.moveDown.get(i)._currentX;
            		int pic = playerStats.shroudAnimations.moveDown.get(i).color;
            		moveFrame(width/6,Y,pic,canvas);
            	}
            }else{
            	if(playerStats.checkBoss){
            		moveFrame(width/6,height/7, 1,canvas); 
				}else{
					moveFrame(width/6,height/7, 0,canvas); 
				}
            	myPaint.setColor(Color.YELLOW);
            	myPaint.setTextSize(textScaler + 24);
            	String sentence = "Tap Anywhere To Continue";
				float sentenceWidth = myPaint.measureText(sentence);
				float startPositionX = (width - sentenceWidth) / 2;
				canvas.drawText("Tap Anywhere To Continue",startPositionX, (4*height)/5, myPaint);
				_thread.endDrawn = true;
            }
		}
		
		public void moveFrame(int X, int Y,int pic,Canvas canvas){
			Bitmap bitmap;
			bitmap = endBanners[pic];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), 
            		bitmap.getHeight(), endwon.returnMatrix(bitmap.getWidth(),
            				bitmap.getHeight(),(int) ((2*width)/3),false), true);
            canvas.drawBitmap(bitmap, X, Y, null);
		}
		
        @Override
        public void onDraw(Canvas canvas) {
        	
        	if(playerStats.unlockedCharacters && settings[1]==0){
        		database.InsertDatabase(settings[0], 1, settings[2], settings[3], settings[4], settings[5], settings[6], settings[7]);
        		settings = database.returnScoreValues(0, -1, -1);
        	}
        	if(eventWatcher.returnUpdate()){
        		//A deadlock happens at the point where the steps are drawn, if this isn't here
        			//synchronized(_thread){
        				doClickActions(eventWatcher.returnPoint());
        				eventWatcher.switchClicked();
        			//}

        		//if(_thread.getGameStatus()){
        		//	touchScreen();
            	//}
        	}
        	if(eventWatcher.returnZoomed()){
        		testZoom();
        		eventWatcher.switchZoomed();
        	}
        	if(!_thread.getGameStatus()){
        		drawStuff(canvas);
        	}else{
        		//This can be replaced in the future to make a cool level over screen at the end
        		//Right now it looks a bit thrown together
            	//tutorialMessages.addMessage("End Of Game Experience","The Experience You Gain At The End Of A Level Is Based On Many Things, " +
        		//		"Such As Enemies Killed And Shroud Explored. An Extra Bonus Will Also Be Given For Completing The Level. " +
        		//		"As You Gain Levels, Certain Dungeon Items Will Be Upgraded To Make Your Next Playthrough Easier. Go To The Player " +
        		//		"Info Screen To See What Has Been Upgraded And The Effect Of That Upgrade",29);
        		//if(!_thread.endDrawn){
        		sounds.turnOff();
        		drawGameOver(canvas);
        		//}
        		//levelOver();
        	}
        }
 
        public void printAnimatedGraphics(int X, int Y, Paint myPaint, Canvas canvas,int alpha, int radius){
        	myPaint.setAlpha(alpha);
        	if(zoomer.getZoom()){
        		myPaint.setStrokeWidth(6);
        	}else{
        		myPaint.setStrokeWidth(3);
        	}
        	canvas.drawCircle(X, Y, radius, myPaint);
        	myPaint.setAlpha(255);
        	myPaint.setStrokeWidth(1);
        }
        
        public int findRatio(int left, int right){
        	return right - left;
        }
        
        public void drawHUD(Canvas canvas, int constant){
        	Bitmap bitmap;
            Paint myPaint = new Paint();
            Paint myText = new Paint();
            //This is for screens with very low resolution
            //myPaint.setTextSize((int) Math.ceil(width/19));
            int enemyX, enemyY;
            myText.setTypeface(Typeface.DEFAULT);
            myText.setStyle(Paint.Style.FILL);
            myText.setStrokeWidth(1);
            myText.setColor(Color.GRAY);
            
            
            myPaint.setTypeface(Typeface.DEFAULT);
            myPaint.setStyle(Paint.Style.STROKE);
            myPaint.setStrokeWidth(1);
            myPaint.setColor(Color.GRAY);

            enemyX = playerPosition.returnXMatrix(cursorPositionX,cursorPositionY);
        	enemyY = playerPosition.returnYMatrix(cursorPositionX,cursorPositionY);
            ClassEnemyStats eStats;
            //Draw HUD
            myPaint.setColor(Color.GRAY);
            canvas.drawRect(constant, ((22)* constant), ((21)* constant), ((34)* constant), myPaint);
            myPaint.setColor(Color.MAGENTA);
            canvas.drawRect(constant-3, ((22)* constant)-3, ((21)* constant)+3, ((34)* constant)+3, myPaint);
            myPaint.setColor(Color.GRAY);
            canvas.drawRect(constant-6, ((22)* constant)-6, ((21)* constant)+6, ((34)* constant)+6, myPaint);
            
            //Draws a frame around the level
            myPaint.setColor(Color.BLACK);
            //myPaint.setStyle(Paint.Style.STROKE);
            canvas.drawRect(constant-3, constant-3, ((20+1)* constant)+3, ((20+1)* constant)+3, myPaint);
            myPaint.setColor(Color.GRAY);
            canvas.drawRect(constant-6, constant-6, ((20+1)* constant)+6, ((20+1)* constant)+6, myPaint);
            myPaint.setColor(Color.GRAY);
            canvas.drawRect(constant-9, constant-9, ((20+1)* constant)+9, ((20+1)* constant)+9, myPaint);
            
            
            //This draws the character picture window
            //myPaint.setColor(Color.WHITE);
            //canvas.drawRect(constant + constant/2, ((20+2)* constant) + constant/2, (constant*4) + constant/2, ((20+6)* constant)+ constant/2, myPaint);
            
            //Draw current character's picture in window
            bitmap = graphic.getGraphic();
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*3,false), true);
            canvas.drawBitmap(bitmap, (2* constant)+constant/2, ((20+3)* constant), null);
            
            //This draws the information window on the right
            canvas.drawRect((12*constant) + (constant + constant/2) - constant/6, ((20+2)* constant) + constant/3, (constant*20) + 3*constant/4, ((20+13)* constant)+ 3*constant/4, myPaint);
            
            //Draw character's attack icon
            bitmap = objectsStatic[0];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, constant + constant/2, (((20+7)* constant) + constant/4), null);
            
            //Draws experience bar
            myPaint.setColor(Color.WHITE);
            //myPaint.setStyle(Paint.Style.STROKE); 
            canvas.drawRect((constant*6), (((20+7)* constant) + (3*constant)/4), (constant*13), (((20+9)* constant)), myPaint);
            //myPaint.setColor(0xff00aa55);
            myText.setColor(Color.GREEN);
            //myPaint.setStyle(Paint.Style.FILL); 
            canvas.drawRect((constant*6)+3, (((20+7)* constant) + (3*constant)/4)+3, 
            		((constant*6)+3) + findRatio((constant*6)+3,(constant*13)-3)*((float)playerStats.player_exp / (float)(playerStats.player_rank*5)), 
            		(((20+9)* constant))-3, myText);
            
            //Draw character's health icon
            bitmap = objectsStatic[3];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, constant + constant/2, (((20+9)* constant) + constant/4), null);
            
            //Draw character's health bar
            myPaint.setColor(Color.WHITE);
            //myPaint.setStyle(Paint.Style.STROKE); 
            canvas.drawRect((constant*4), (((20+9)* constant) + (3*constant)/4), (constant*13), (((20+11)* constant)), myPaint);
            
            if (ref.enemyNum(enemyX,enemyY) == 0){
            	myText.setColor(0xffcc3333);
            }else{
            	myText.setColor(-10027008);
            }
            //myPaint.setStyle(Paint.Style.FILL); 
            canvas.drawRect((constant*4)+3, (((20+9)* constant) + (3*constant)/4)+3, 
            		((constant*4)+3) + findRatio((constant*4)+3,
            				(constant*13)-3)*((float)(playerStats.player_currenthealth) 
            						/ (float)(playerStats.getPlayerMaxHealth())), 
            		(((20+11)* constant))-3, myText);
            
            if (ref.enemyNum(enemyX,enemyY) != 0 && !playerStats.sHub){
            	myText.setColor(0xffcc3333);
            	canvas.drawRect((constant*4)+3, (((20+9)* constant) + (3*constant)/4)+3, 
            		((constant*4)+3) + findRatio((constant*4)+3,
            				(constant*13)-3)*((float)((playerStats.player_currenthealth)-playerStats.enemyStrike(ref.returnEnemyObj(enemyX, enemyY))) 
            						/ (float)(playerStats.getPlayerMaxHealth())), 
            		(((20+11)* constant))-3, myText);
            }
            //Draw character's magic icon
            bitmap = objectsStatic[5];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, constant + constant/2, (((20+11)* constant) + constant/4), null);
            
            //Draw character's mana bar
            myPaint.setColor(Color.WHITE);
            //myPaint.setStyle(Paint.Style.STROKE); 
            canvas.drawRect((constant*4), (((20+11)* constant) + (3*constant)/4), (constant*13), (((20+13)* constant)), myPaint);
            myText.setColor(0xff0099CC);
            //myPaint.setStyle(Paint.Style.FILL); 
            if (playerStats.getPlayerMaxMana() > 0){
            canvas.drawRect((constant*4)+3, (((20+11)* constant) + (3*constant)/4)+3, 
            		((constant*4)+3) + findRatio((constant*4)+3,(constant*13)-3)*((float)(playerStats.player_currentmana) / (float)(playerStats.getPlayerMaxMana())),
            		(((20+13)* constant))-3, myText);
            }else{
            	canvas.drawRect((constant*4)+3, (((20+11)* constant) + (3*constant)/4)+3, 
                		((constant*4)+3) + findRatio((constant*4)+3,(constant*13)-3)*(1),
                		(((20+13)* constant))-3, myText);
            }
            //myPaint.setStyle(Paint.Style.STROKE); 
            
            //Draw character's gold icon
            bitmap = objectsStatic[1];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, (constant*5)+constant/2, ((20+2)* constant) + constant/2, null);
            
            //Draw character's pious icon
            bitmap = objectsStatic[6];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, (constant*9)+constant/2, ((20+2)* constant) + constant/2, null);
            
            //Draw character's health potion icon
            bitmap = objectsStatic[2];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, (constant*5)+constant/2, (((20+5)* constant)), null);
            
            //Draw character's mana potion icon
            bitmap = objectsStatic[4];
            bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
            canvas.drawBitmap(bitmap, (constant*9)+constant/2, (((20+5)* constant)), null);
            
            //This prints out all of the game text
            myText.setColor(Color.BLACK);
            //myPaint.setStrokeWidth(2);
            //myPaint.setTextSize(scaledSize);
            myText.setTextSize(textScaler + 16);
            myText.setStrokeWidth(3);
    		canvas.drawText(String.valueOf(playerStats.player_rank), (constant*2)+constant/2-1, ((20+6)* constant)+1, myText);
    		canvas.drawText(String.valueOf(playerStats.player_rank), (constant*2)+constant/2+1, ((20+6)* constant)+1, myText);
    		canvas.drawText(String.valueOf(playerStats.player_rank), (constant*2)+constant/2-1, ((20+6)* constant)-1, myText);
    		canvas.drawText(String.valueOf(playerStats.player_rank), (constant*2)+constant/2+1, ((20+6)* constant)-1, myText);
    		
            if (playerStats.player_rank<4){
            	myText.setColor(Color.GREEN);
            }else if (playerStats.player_rank<8){
            	myText.setColor(Color.YELLOW);
            }else{
            	myText.setColor(Color.RED);
            }
            
            canvas.drawText(String.valueOf(playerStats.player_rank), (constant*2)+constant/2, ((20+6)* constant), myText);
            myText.setStrokeWidth(1);
            
            myText.setColor(Color.WHITE);
            canvas.drawText(String.valueOf(playerStats.player_gold), (constant*7)+ constant/2, ((20+3)* constant)+ constant/2, myText);
            canvas.drawText(String.valueOf(playerStats.player_piety), (constant*12), ((20+3)* constant)+ constant/2, myText);
            canvas.drawText(String.valueOf(playerStats.player_hpotions), (constant*7)+ constant/2, ((20+6)* constant), myText);
            canvas.drawText(String.valueOf(playerStats.player_mpotions), (constant*12), ((20+6)* constant), myText);
            
            //playerStrike(enemy,true)
            //canvas.drawText(String.valueOf(playerStats.returnAttack()), (constant*4), (((20+8)* constant) + constant/2), myPaint);
            myText.setColor(Color.WHITE);
            canvas.drawText(playerStats.player_exp + " / " + (playerStats.player_rank*5), (constant*9), (((20+8)* constant)+ (7*constant)/10), myText);
            canvas.drawText(playerStats.player_currenthealth + " / " + playerStats.getPlayerMaxHealth(), (constant*7), (((20+10)* constant)+ (7*constant)/10), myText);
            canvas.drawText(playerStats.player_currentmana + " / " + playerStats.getPlayerMaxMana(), (constant*7), (((20+12)* constant)+ (7*constant)/10), myText);
            
            //Prints the symptoms of the player. If any.
            printPlayerModifiers(playerStats, constant + constant/4, ((20+6)* constant) + constant/4, canvas, constant);
            
            //Write the character info in the bar on the right
            myText.setTextSize(textScaler + 12);
            myText.setTextAlign(Paint.Align.CENTER);
            //myPaint.setStrokeWidth(1);
            
            if (ref.enemyNum(enemyX,enemyY) == 0){
            	
                //myPaint.setStrokeWidth(2);
                //myPaint.setTextSize(scaledSize);
            	myText.setTextSize(textScaler + 16);
            	playerStats.forHUB = true;
            	int predictedAttack = playerStats.playerStrike(new ClassEnemyStats(0,0,0,0, false, false, 
                		false, false, false, false, false, false, false, false,false, false, false, 
                		false,false),true);
            	playerStats.forHUB = false;
            	if (predictedAttack > playerStats.player_attack){
            		myText.setColor(Color.GREEN);
                }else if(predictedAttack < playerStats.player_attack){
                	myText.setColor(Color.RED);
                }else{
                	myText.setColor(Color.WHITE);
                }
            	//myPaint.setStyle(Paint.Style.FILL); 
            	canvas.drawText(String.valueOf(predictedAttack), (constant*4), (((20+8)* constant) + constant/2), myText);
            	//myPaint.setStyle(Paint.Style.STROKE); 
            	//myPaint.setStrokeWidth(1);
            	myText.setColor(Color.WHITE);
            	
            }
            myText.setTextSize(textScaler + 12);
            //canvas.drawText(Draws.raceStrings[playerStats.player_race] + " " + Draws.classStrings[playerStats.player_class], (3*constant) + constant/2, ((23)* constant), myPaint);
            
            //myPaint.setTextScaleX((float) 1.25);
            if (ref.enemyNum(enemyX,enemyY) == 0 
            		&& ref.objNum(enemyX,enemyY) == 0 
            		&& ref.glyphNum(enemyX,enemyY) == 0 
            		&& ref.shopNum(enemyX,enemyY) == 0 
            		&& ref.altarNum(enemyX,enemyY) == 0){

            	if (playerStats.selectedSpell == -1){
            		canvas.drawText(Draws.raceStrings[playerStats.player_race] + " " + Draws.classStrings[playerStats.player_class], (17*constant), ((20+3)* constant)+ constant/2, myText);
            		canvas.drawText("Current Effects", (17*constant), (((float)25.75)* constant)+ constant/2, myText);
            		myText.setColor(Color.GREEN);
                	breakDrawText(playerStats.returnGoodEffects(), canvas, myText,(float)17,(float)27.25, constant);
                	myText.setColor(Color.RED);
                	breakDrawText(playerStats.returnBadEffects(), canvas, myText,(float)17,(float)29.5, constant);
                	//If the player is worshipping a god. Put the effects on the right
                    if (playerStats.worshipGod){
                    	myText.setTextSize(textScaler + 10);
                    	myText.setColor(Color.YELLOW);
                    	breakDrawText("Follower Of", canvas, myText,17,(float)24.5, constant);
                    	breakDrawText(Draws.godNames[playerStats.playerGod-1], canvas, myText,17,(float)25.3, constant);
                    }
            	}
            	//Draw the spell slots
            	drawSpellSlots(canvas,true, myText,constant);
            	
            }else if (ref.enemyNum(enemyX,enemyY) != 0){

                //myPaint.setStrokeWidth(2);
                //myPaint.setStyle(Paint.Style.STROKE); 
            	myText.setTextSize(textScaler + 16);
            	playerStats.forHUB = true;
            	int predictedAttack = playerStats.playerStrike(ref.returnEnemyObj(enemyX,enemyY),true);
            	playerStats.forHUB = false;
            	if (predictedAttack > playerStats.player_attack){
            		myText.setColor(Color.GREEN);
                }else if(predictedAttack < playerStats.player_attack){
                	myText.setColor(Color.RED);
                }else{
                	myText.setColor(Color.WHITE);
                }
            	//myPaint.setStyle(Paint.Style.FILL); 
            	//myPaint.setStrokeWidth(3);
            	canvas.drawText(String.valueOf(predictedAttack), (constant*4), (((20+8)* constant) + constant/2), myText);
            	//myPaint.setStyle(Paint.Style.STROKE); 
            	myText.setColor(Color.WHITE);
            	//myPaint.setStrokeWidth(1);
            	myText.setTextSize(textScaler + 12);
            	
            	eStats = ref.returnEnemyObj(enemyX,enemyY);
            	//Draw the enemy's name
            	if (ref.returnEnemyObj(enemyX,enemyY).level <= 9){
            		canvas.drawText(Draws.enemyStrings[ref.enemyNum(enemyX,enemyY)-1], (18*constant), ((20+3)* constant)+ constant/2, myText);
            	}else{
            		//The enemy is the boss
            		canvas.drawText(Draws.enemyBossStrings[ref.enemyNum(enemyX,enemyY)-1], (18*constant), ((20+3)* constant)+ constant/2, myText);
            	}
            	
            	myText.setColor(Color.WHITE);
            	
            	//Draw the enemy's hit outcome
            	myText.setTextAlign(Paint.Align.LEFT);
            	canvas.drawText("-Hit Estimate-", (16*constant)+ constant/2, ((20+4)* constant)+ constant/2, myText);
            	myText.setTextAlign(Paint.Align.CENTER);
            	if(!playerStats.sHub){
            	switch(playerStats.calcWin(ref.returnEnemyObj(enemyX, enemyY), ref.exploredAround(enemyX, enemyY))){
            		case 1: 
            			myText.setColor(Color.GREEN);
            			canvas.drawText("Victory", (18*constant), ((20+5)* constant)+ constant/2, myText);
            			break;
            		case 0:
            			myText.setColor(Color.YELLOW);
            			canvas.drawText("Safe", (18*constant), ((20+5)* constant)+ constant/2, myText);
            			break;
            		default:
            			myText.setColor(Color.RED);
            			canvas.drawText("Death", (18*constant), ((20+5)* constant)+ constant/2, myText);
            			break;
            	}
            	}else{
            		myText.setColor(Color.WHITE);
        			canvas.drawText("Unknown", (18*constant), ((20+5)* constant)+ constant/2, myText);
            	}
            	
            	//Attack Icon
                bitmap = objectsStatic[0];
                bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), icon1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (constant*1.5),false), true);
                canvas.drawBitmap(bitmap, (constant*14), (((20+7)* constant)), null);

                myText.setColor(Color.WHITE);
                //myPaint.setStyle(Paint.Style.STROKE);
                //myPaint.setStrokeWidth(2);
                canvas.drawText(""+ref.returnEnemyObj(enemyX,enemyY).getAttack(), (constant*16), (((20+8)* constant)), myText);
            	
                //Lives Icon
                bitmap = objectsStatic[7];
                bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), icon1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (constant*1.5),false), true);
                canvas.drawBitmap(bitmap, (constant*17), (((20+7)* constant)), null);
                canvas.drawText(""+ref.returnEnemyObj(enemyX,enemyY).extraLives, (constant*19)+ constant/2, (((20+8)* constant)), myText);
                
                //Health Icon
                bitmap = objectsStatic[3];
                bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), icon1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (constant*1.5),false), true);
                canvas.drawBitmap(bitmap, (constant*14), (((20+9)* constant)), null);
                
                //Enemy health Bar
                myPaint.setColor(Color.WHITE);
                //myPaint.setStyle(Paint.Style.STROKE);
               // myPaint.setStrokeWidth(3);
                canvas.drawRect((constant*16), ((20+9)* constant), (constant*20), (((20+10)* constant)+ constant/2), myPaint);
                myText.setColor(-10027008);
                //myPaint.setStyle(Paint.Style.FILL); 
                canvas.drawRect((constant*16)+3, ((20+9)* constant) +3, 
                		((constant*16)+3) + findRatio((constant*16)+3,(constant*20)-3)*((float)eStats.getCurrentHealth() / (float)eStats.getHealth()), 
                		(((20+10)* constant)+ constant/2) -3, myText);
                
                if(!playerStats.sHub){
                	
                	myText.setColor(0xffcc3333);
                    //myPaint.setStyle(Paint.Style.FILL); 
                    canvas.drawRect((constant*16)+3, ((20+9)* constant) +3, 
                    		((constant*16)+3) + findRatio((constant*16)+3,(constant*20)-3)*(
                    				(float)(eStats.getCurrentHealth() - playerStats.playerStrike(ref.returnEnemyObj(enemyX, enemyY),true))
                    				/ (float)eStats.getHealth()), 
                    		(((20+10)* constant)+ constant/2) -3, myText);
                	
                if(playerStats.selectedSpell>-1){	
                if(playerStats.currentGlyphs[playerStats.selectedSpell] == 5 ||
                		playerStats.currentGlyphs[playerStats.selectedSpell] == 16 ||
                		playerStats.currentGlyphs[playerStats.selectedSpell] == 18 ||
                		playerStats.currentGlyphs[playerStats.selectedSpell] == 19)	{
                	int magicDamage = 0;
                	switch(playerStats.currentGlyphs[playerStats.selectedSpell]){
                		case 5: magicDamage = playerStats.returnMagicDamage(4*playerStats.player_rank,ref.returnEnemyObj(enemyX,enemyY),true);break;
                		case 16: magicDamage = playerStats.returnMagicDamage(playerStats.player_currentmana,ref.returnEnemyObj(enemyX,enemyY),true);break;
                		case 18: magicDamage = playerStats.returnMagicDamage(playerStats.player_gold/4,ref.returnEnemyObj(enemyX,enemyY),true); break;
                		case 19: magicDamage = playerStats.returnMagicDamage(playerStats.findEnemies(ref),ref.returnEnemyObj(enemyX,enemyY),true); break;
                		default: break;
                	}
                	
                	magicDamage = eStats.getCurrentHealth() - magicDamage;
                	if(magicDamage<0){
                		magicDamage = 0;
                	}
                	
                	myText.setColor(0xff3300CC);
                    //myPaint.setStyle(Paint.Style.FILL); 
                    canvas.drawRect((constant*16)+3, ((20+9)* constant) + (3*constant/4)+3, 
                    		((constant*16)+3) + findRatio((constant*16)+3,(constant*20)-3)*((float)eStats.getCurrentHealth() / (float)eStats.getHealth()), 
                    		(((20+10)* constant)+ constant/2) -3, myText);
                	
                    myText.setColor(0xff0099CC);
                    //myPaint.setStyle(Paint.Style.FILL); 
                    canvas.drawRect((constant*16)+3, ((20+9)* constant) + (3*constant/4) +3, 
                    		((constant*16)+3) + findRatio((constant*16)+3,(constant*20)-3)*(
                    				(float)(magicDamage)
                    				/ (float)eStats.getHealth()), 
                    		(((20+10)* constant)+ constant/2) -3, myText);
                }
                }
                }
                
                /*myPaint.setTextAlign(Paint.Align.CENTER);
        		myPaint.setStrokeWidth(3);
        		myPaint.setStyle(Paint.Style.FILL);
        		myPaint.setTypeface(Typeface.DEFAULT_BOLD);
        		myPaint.setColor(Color.BLACK);
        		
        		canvas.drawText(eStats.getCurrentHealth() + " / " + eStats.getHealth(), (constant*18)-1, (30)* constant-1, myPaint);
        		canvas.drawText(eStats.getCurrentHealth() + " / " + eStats.getHealth(), (constant*18)+1, (30)* constant-1, myPaint);
        		canvas.drawText(eStats.getCurrentHealth() + " / " + eStats.getHealth(), (constant*18)-1, (30)* constant+1, myPaint);
        		canvas.drawText(eStats.getCurrentHealth() + " / " + eStats.getHealth(), (constant*18)+1, (30)* constant+1, myPaint);*/
                
                
                myText.setColor(Color.WHITE);
                //myPaint.setStyle(Paint.Style.STROKE);
                //myPaint.setStrokeWidth(2);

                canvas.drawText(eStats.getCurrentHealth() + " / " + eStats.getHealth(), (constant*18), (30)* constant, myText);
                
                //Draw enemy image
            	bitmap = enemiesStatic[getEnemyPos(ref.enemyNum(enemyX,enemyY)-1)];
            	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), enemy1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
    			canvas.drawBitmap(bitmap, (14*constant), ((20+3)* constant)+ constant/2, null);
    			
    			//Prints the enemy's level on it's picture
    			if(!playerStats.sHub){
    				myText.setTextAlign(Paint.Align.CENTER);
            		//myPaint.setStrokeWidth(3);
            		//myPaint.setStyle(Paint.Style.FILL);
    				myText.setTypeface(Typeface.DEFAULT_BOLD);
    				myText.setColor(Color.BLACK);
            		canvas.drawText(String.valueOf(ref.returnEnemyObj(enemyX, enemyY).level), (14*constant)+7, (((20+3)* constant)+ constant/2)+(bitmap.getHeight())-3, myText);
            		canvas.drawText(String.valueOf(ref.returnEnemyObj(enemyX, enemyY).level), (14*constant)+9, (((20+3)* constant)+ constant/2)+(bitmap.getHeight())-3, myText);
            		canvas.drawText(String.valueOf(ref.returnEnemyObj(enemyX, enemyY).level), (14*constant)+7, (((20+3)* constant)+ constant/2)+(bitmap.getHeight())-7, myText);
            		canvas.drawText(String.valueOf(ref.returnEnemyObj(enemyX, enemyY).level), (14*constant)+9, (((20+3)* constant)+ constant/2)+(bitmap.getHeight())-7, myText);
    				
    				
                if (ref.returnEnemyObj(enemyX, enemyY).level<4){
                	myText.setColor(Color.GREEN);
                }else if (ref.returnEnemyObj(enemyX, enemyY).level<8){
                	myText.setColor(Color.YELLOW);
                }else{
                	myText.setColor(Color.RED);
                }
                myText.setTextSize(textScaler + 12);
        		//myPaint.setStyle(Paint.Style.FILL); 
                //myPaint.setStrokeWidth(1);
        		canvas.drawText(String.valueOf(ref.returnEnemyObj(enemyX, enemyY).level), (14*constant)+8, (((20+3)* constant)+ constant/2)+(bitmap.getHeight())-5, myText);
    			}
        		printModifiers(ref.returnEnemyObj(enemyX, enemyY), 14, 26, canvas,constant);
        		
        		drawSpellSlots(canvas, false, myText,constant);
    			
            }else if(ref.objNum(enemyX,enemyY) != 0){
            	//Draws.gameImages[ref.objNum(x,y)-1]
            	
            	//Draw Object Picture
            	bitmap = objectsStatic[ref.objNum(enemyX,enemyY)-1];
            	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), icon1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
    			canvas.drawBitmap(bitmap, (16*constant), ((20+5)* constant)+ constant/2, null);
            	
    			//myPaint.setStrokeWidth(1);
    			myText.setTextSize(textScaler + 16);
            	//Draw the Objects's name
    			if((ref.objNum(enemyX,enemyY)-1) != 1){
    				canvas.drawText(Draws.iconDescription[ref.objNum(enemyX,enemyY)-1], (17*constant), ((20+9)* constant)+ constant/2, myText);
    			}else{
    				canvas.drawText("+ " + (10 + playerStats.goldBonus) + " Gold", (17*constant), ((20+9)* constant)+ constant/2, myText);
    			}
            }
            else if(ref.shopNum(enemyX,enemyY) != 0){
            	//Draws.gameImages[ref.objNum(x,y)-1]
            	
            	if (!sounds.returnLastPlayedLocationSame()){
            		sounds.playSound(14);
            	}
            	
            	//tutorialMessages.addMessage("Clicked On A Store","You Have Clicked On A Dungeon Shop. The Cost Of The Item Is Located In The Yellow Coin. " +
            	//		"Your Gold Is Located In The Bottom Left Hand Corner Of The Screen. The Buy Item Box Will Turn Yellow If You Have Enough Gold. Tap It To Buy " +
            	//		"The Item",9);
            	//Draw Object Picture
            	bitmap = locationStatic[0];
            	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), loc1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
    			canvas.drawBitmap(bitmap, (17*constant)+ constant/2, ((23)* constant)+ constant/2, null);
    			
    			myText.setColor(Color.GRAY);
    			//myPaint.setStyle(Paint.Style.FILL); 
    			canvas.drawCircle((16*constant)- constant/2, (24)* constant+ constant/2, constant, myText);
    			myText.setColor(Color.YELLOW);
    			canvas.drawCircle((16*constant)- constant/2, (24)* constant+ constant/2, constant-3, myText);
    			
    			myText.setTextSize(textScaler + 18);
    			//myPaint.setStrokeWidth(3);
    			myText.setColor(Color.BLACK);
    			canvas.drawText(""+returnTotalCost(ref.shopObj(enemyX, enemyY).returnCost()),(16*constant)- constant/2, ((24)* constant)+ (2*constant)/3, myText);
    			
    			myText.setColor(Color.WHITE);
    			//myPaint.setStyle(Paint.Style.FILL); 
    			//myPaint.setStrokeWidth(1);
    			myText.setTextSize(textScaler + 16);
    			if(ref.shopNum(enemyX,enemyY) <11 ){
    			canvas.drawText(Draws.itemPrefixes[ref.shopNumTech(enemyX,enemyY)] + 
    					" " +Draws.itemSuffixes[ref.shopNum(enemyX,enemyY)-1], 
    					(17*constant), ((27)* constant)+ constant/2, myText);
    			}else{
    				//This will appear if the upgradable shops are not present
    				canvas.drawText(ref.shopObj(enemyX,enemyY).otherShopNames(),(17*constant), ((27)* constant)+ constant/2, myText);
    			}
    			
    			if(!playerStats.noStores){
    				myText.setTextSize(textScaler + 10);
    				//Draw the Objects's name
    				breakDrawText(ref.shopObj(enemyX,enemyY).printEffectsShops(playerStats), canvas, myText,17,29, constant);
    				myPaint.setColor(Color.DKGRAY);
    				canvas.drawRect((14*constant), (32)* constant- constant/2, (20*constant), (33)* constant, myPaint);
    				if(playerStats.player_gold >= returnTotalCost(ref.shopObj(enemyX, enemyY).returnCost())){
    					myText.setColor(Color.YELLOW);
    				}else{
    					myText.setColor(Color.GRAY);
    				}
    				canvas.drawRect((14*constant)+3, (32)* constant- constant/2+3, (20*constant)-3, (33)* constant-3, myText);
    				myText.setColor(Color.BLACK);
    				//myPaint.setStrokeWidth(3);
    				canvas.drawText("Buy Item",(17*constant), 33 * constant - constant/2, myText);
    			}
            }
            else if(ref.altarNum(enemyX,enemyY) != 0){
            	//Draws.gameImages[ref.objNum(x,y)-1]
            	//Draw Object Picture
            	//bitmap = gods[ref.altarNum(enemyX,enemyY)-1];
            	//bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), loc1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),scale*2), true);
    			//canvas.drawBitmap(bitmap, (16*constant), ((23)* constant), null);
            	
            	if (!sounds.returnLastPlayedLocationSame()){
            		sounds.playSound(13);
            	}
            	
            	myText.setStyle(Paint.Style.FILL); 
    			//myPaint.setStrokeWidth(1);
            	myText.setTextSize(textScaler + 14);
    			canvas.drawText(Draws.godNames[ref.altarNum(enemyX,enemyY)-1], (17*constant), ((23)* constant)+ constant/2, myText);
    			myText.setTextSize(textScaler + 10);
    			breakDrawText(Draws.godDescriptions[ref.altarNum(enemyX,enemyY)-1], canvas, myText,17, (float) 24.5, constant);
    			
    			if (!playerStats.worshipGod){
            		//tutorialMessages.addMessage("\tClicked On An Altar","You Have Clicked On The Home Of A God. " +
            		//		"By Worshipping a God, You Gain a Blessing and Sometimes a Curse." +
            		//		" You Can Only Worship One God Per Dungeon, So Choose Wisely",10);
    				myText.setTextSize(textScaler + 10);
    				//Draw the Objects's name
    				myText.setTextSize(textScaler + 10);
                	//Draw the Objects's name
        			//breakDrawText(Draws.godDescriptions[ref.altarNum(enemyX,enemyY)-1], canvas, myPaint,17,29);
    				myText.setColor(Color.GREEN);
        			breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][0], canvas, myText,17,28, constant);
        			myText.setColor(Color.RED);
        			breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][1], canvas, myText,17, (float) 29.5, constant);
        			myText.setColor(Color.DKGRAY);
    				canvas.drawRect((14*constant), (32)* constant- constant/2, (20*constant), (33)* constant, myText);
    				myText.setColor(Color.YELLOW);
    				canvas.drawRect((14*constant)+3, (32)* constant- constant/2+3, (20*constant)-3, (33)* constant-3, myText);
    				myText.setColor(Color.BLACK);
    				//myPaint.setStrokeWidth(3);
    				canvas.drawText("Worship",(17*constant), 33 * constant - constant/2, myText);
    			}
    			else if(ref.altarObj(enemyX,enemyY).worshipped){
    					//tutorialMessages.addMessage("\tYou Worship This God","You Have Already Gained This God's Blessings, Why Not Gain A Bit More Power?" +
    					//		" By Doing Things That This God Likes, You Will Be Able To Perform The Rituals On The Bottom Right Hand Side. Don't Worry If" +
    					//		" You Do Something You God Disapproves Of. You Will Not Suffer For Negative Piety",22);
    					myText.setTextSize(textScaler + 10);
    					float Y=0;
    					int ritual1 = Draws.ritualLevels[ref.altarNum(enemyX,enemyY)-1][0];
    					int ritual2 = Draws.ritualLevels[ref.altarNum(enemyX,enemyY)-1][1];
    					int ritual3 = Draws.ritualLevels[ref.altarNum(enemyX,enemyY)-1][2];
    					
    					boolean done1 = ref.altarObj(enemyX, enemyY).ritual1;
    					boolean done2 = ref.altarObj(enemyX, enemyY).ritual2;
    					boolean done3 = ref.altarObj(enemyX, enemyY).ritual3;
                		//Draw the Objects's name
    					bitmap = tileStatic[9];
    	            	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), loc1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int)(constant*1.5),false), true);
    					
    					myPaint.setColor(Color.LTGRAY);
        				canvas.drawRect((15*constant)+constant/2, (27)* constant, (20*constant)+constant/2, (29)* constant - constant/2, myPaint);
        				myText.setColor(Color.YELLOW);
        				canvas.drawRect((15*constant)+constant/2+3, (27)* constant+3, (20*constant)+constant/2-3, (29)* constant- constant/2 -3, myText);
        				
        				myPaint.setColor(Color.LTGRAY);
        				canvas.drawRect((15*constant)+constant/2, (29)* constant, (20*constant)+constant/2, (30)* constant + constant/2, myPaint);
        				myText.setColor(Color.YELLOW);
        				canvas.drawRect((15*constant)+constant/2+3, (29)* constant+3, (20*constant)+constant/2-3, (30)* constant + constant/2-3, myText);
        				
        				myPaint.setColor(Color.LTGRAY);
        				canvas.drawRect((15*constant)+constant/2, (31)* constant, (20*constant)+constant/2, (33)* constant - constant/2, myPaint);
        				myText.setColor(Color.YELLOW);
        				canvas.drawRect((15*constant)+constant/2+3, (31)* constant+3, (20*constant)+constant/2-3, (33)* constant- constant/2 -3, myText);
    					
        				canvas.drawBitmap(bitmap, (14*constant)-constant/3, ((27)* constant), null);
        				canvas.drawBitmap(bitmap, (14*constant)-constant/3, ((29)* constant), null);
        				canvas.drawBitmap(bitmap, (14*constant)-constant/3, ((31)* constant), null);
        				
        				myText.setColor(Color.YELLOW);
        				myText.setTextAlign(Paint.Align.CENTER);
        				myText.setTextSize(textScaler + 14);

    					canvas.drawText(""+ritual1 * 10,(14*constant)+2*constant/5, 28 * constant, myText);
            			canvas.drawText(""+ritual2 * 10,(14*constant)+2*constant/5, 30 * constant, myText);
            			canvas.drawText(""+ritual3 * 10,(14*constant)+2*constant/5, 32 * constant, myText);
            			
            			
            			//playerStats.playerTech[7];
            			if(!done1){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (27)* constant, (20*constant)+constant/2, (29)* constant - constant/2, myPaint);
            				myText.setColor(Color.GREEN);
            				canvas.drawRect((15*constant)+constant/2+3, (27)* constant+3, (20*constant)+constant/2-3, (29)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 9);
            				if(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][2].length() > 22){Y = (float) 27.70;}else{Y = (float) 28;}
            				breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][2], canvas, myText,(float)18, (float)Y, constant);
            			}
            			else if(done1){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (27)* constant, (20*constant)+constant/2, (29)* constant - constant/2, myPaint);
            				myText.setColor(Color.YELLOW);
            				canvas.drawRect((15*constant)+constant/2+3, (27)* constant+3, (20*constant)+constant/2-3, (29)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 28;
            				breakDrawText("Used", canvas, myText,(float)18, (float) Y, constant);
            			}
            			else{
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (27)* constant, (20*constant)+constant/2, (29)* constant - constant/2, myPaint);
            				myText.setColor(Color.RED);
            				canvas.drawRect((15*constant)+constant/2+3, (27)* constant+3, (20*constant)+constant/2-3, (29)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 28;
            				breakDrawText("Locked", canvas, myText,(float)18, (float) Y, constant);
            			}
            			if(!done2){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (29)* constant, (20*constant)+constant/2, (30)* constant + constant/2, myPaint);
            				myText.setColor(Color.GREEN);
            				canvas.drawRect((15*constant)+constant/2+3, (29)* constant+3, (20*constant)+constant/2-3, (30)* constant + constant/2-3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 9);
            				if(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][3].length() > 22){Y = (float) 29.70;}else{Y = (float) 30;}
            				breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][3], canvas, myText,(float)18, (float) Y, constant);
            			}
            			else if(done2){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (29)* constant, (20*constant)+constant/2, (30)* constant + constant/2, myPaint);
            				myText.setColor(Color.YELLOW);
            				canvas.drawRect((15*constant)+constant/2+3, (29)* constant+3, (20*constant)+constant/2-3, (30)* constant + constant/2-3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 30;
            				breakDrawText("Used", canvas, myText,(float)18, (float) Y, constant);
            			}
            			else{
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (29)* constant, (20*constant)+constant/2, (30)* constant + constant/2, myPaint);
            				myText.setColor(Color.RED);
            				canvas.drawRect((15*constant)+constant/2+3, (29)* constant+3, (20*constant)+constant/2-3, (30)* constant + constant/2-3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 30;
            				breakDrawText("Locked", canvas, myText,(float)18, (float) Y, constant);
            			}
            			if(!done3){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (31)* constant, (20*constant)+constant/2, (33)* constant - constant/2, myPaint);
            				myText.setColor(Color.GREEN);
            				canvas.drawRect((15*constant)+constant/2+3, (31)* constant+3, (20*constant)+constant/2-3, (33)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 9);
            				if(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][4].length() > 22){Y = (float) 31.70;}else{Y = (float) 32;}
            				breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][4], canvas, myText,(float)18, (float) Y, constant);
            			}
            			else if(done3){
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (31)* constant, (20*constant)+constant/2, (33)* constant - constant/2, myPaint);
            				myText.setColor(Color.YELLOW);
            				canvas.drawRect((15*constant)+constant/2+3, (31)* constant+3, (20*constant)+constant/2-3, (33)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 32;
            				breakDrawText("Used", canvas, myText,(float)18, (float) Y, constant);
            			}
            			else{
            				myPaint.setColor(Color.LTGRAY);
            				canvas.drawRect((15*constant)+constant/2, (31)* constant, (20*constant)+constant/2, (33)* constant - constant/2, myPaint);
            				myText.setColor(Color.RED);
            				canvas.drawRect((15*constant)+constant/2+3, (31)* constant+3, (20*constant)+constant/2-3, (33)* constant- constant/2 -3, myText);
            				myText.setColor(Color.BLACK);
            				myText.setTextSize(textScaler + 14);
            				Y = 32;
            				breakDrawText("Locked", canvas, myText,(float)18, (float) Y, constant);
            			}
            			
            			
    					
        				//myPaint.setColor(Color.LTGRAY);
        				//canvas.drawRect((14*constant), (32)* constant- constant/2, (20*constant), (33)* constant, myPaint);
        				//myPaint.setColor(Color.YELLOW);
        				//canvas.drawRect((14*constant)+3, (32)* constant- constant/2+3, (20*constant)-3, (33)* constant-3, myPaint);
        				//myPaint.setColor(Color.BLACK);
        				//myPaint.setStrokeWidth(3);
        				//canvas.drawText("Follower",(17*constant), 33 * constant - constant/2, myPaint);
    			}
    			else if(!ref.altarObj(enemyX,enemyY).worshipped){
    					//tutorialMessages.addMessage("\tYou Do Not Worship This God","You Can Only Worship One God At A Time Per Game. Keep In Mind That Some" +
    					//	" Gods Benefit Certain Characters More Than Others, So Be Sure To Choose Wisely",23);
    					myText.setTextSize(textScaler + 10);
    					//Draw the Objects's name
    					//breakDrawText(Draws.godDescriptions[ref.altarNum(enemyX,enemyY)-1], canvas, myPaint,17,29);
    					myText.setColor(Color.GREEN);
    					breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][0], canvas, myText,17,28, constant);
    					myText.setColor(Color.RED);
    					breakDrawText(Draws.ritualDescriptions[ref.altarNum(enemyX,enemyY)-1][1], canvas, myText,17, (float) 29.5, constant);
        				myPaint.setColor(Color.LTGRAY);
        				canvas.drawRect((14*constant), (32)* constant- constant/2, (20*constant), (33)* constant, myPaint);
        				myText.setColor(Color.RED);
        				canvas.drawRect((14*constant)+3, (32)* constant- constant/2+3, (20*constant)-3, (33)* constant-3, myText);
        				myText.setColor(Color.BLACK);
        				//myPaint.setStrokeWidth(3);
        				canvas.drawText("God Shunned",(17*constant), 33 * constant - constant/2, myText);
    			}
            }
            else{
            	//Draw Glyph Picture
            	bitmap = glyphsStatic[ref.glyphNum(enemyX,enemyY)-1];
            	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), glyph1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant*2,false), true);
    			canvas.drawBitmap(bitmap, (16*constant), ((20+5)* constant)+ constant/2, null);
            	
    			//myPaint.setStrokeWidth(1);
    			myText.setTextSize(textScaler + 16);
            	//Draw the Objects's name
            	canvas.drawText(Draws.glyphStrings[ref.glyphNum(enemyX,enemyY)-1], (17*constant), ((20+4)* constant)+ constant/2, myText);
            	
            	//myPaint.setStrokeWidth(1);
            	myText.setTextSize(textScaler + 10);
            	myText.setTextAlign(Paint.Align.CENTER);
    			//myPaint.setStyle(Paint.Style.FILL); 
    			breakDrawText(Draws.glyphDescriptions[ref.glyphNum(enemyX,enemyY)-1], canvas, myText,17,29, constant);
    			myText.setTextSize(textScaler + 16);
    			canvas.drawText("Mana Cost: " + playerStats.glyphInfo.returnCost(ref.glyphNum(enemyX,enemyY)-1,playerStats), (17*constant), ((32)* constant), myText);
    			myText.setTextSize(textScaler + 10);
    			//Draw the Objects's name
            	//canvas.drawText(Draws.glyphDescriptions[ref.glyphNum(enemyX,enemyY)-1], (17*constant), ((20+9)* constant)+ constant/2, myPaint);
            }
            //myPaint.setStyle(Paint.Style.FILL); 
            if(playerStats.shroudAnimations.shroudHealth.size()>0){
            	playerStats.shroudAnimations.moveAnimatedShroud((int)(((constant*4)+3) + findRatio((constant*4)+3,
        				(constant*13)-3)*((float)(playerStats.getPlayerMaxHealth()/2) 
        						/ (float)(playerStats.getPlayerMaxHealth()))),(((20+11)* constant))-3,1);
            	for (int i = 0; i < playerStats.shroudAnimations.shroudHealth.size();i++){
            		int X = playerStats.shroudAnimations.shroudHealth.get(i)._currentX;
            		int Y = playerStats.shroudAnimations.shroudHealth.get(i)._currentY;
            		if (!playerStats.vampireRegen){
            			myText.setColor(Color.RED);
            		}else{
            			myText.setColor(0xff9900FF);
            		}
            		
            		if(!zoomer.getZoom() || playerStats.shroudAnimations.shroudHealth.get(i).unZoom){
            			printAnimatedGraphics(X,Y,myText,canvas,100, constant/3);
            		}else{
            			printAnimatedGraphics(X,Y,myText,canvas,100, 2*constant/3);
            		}
            	}
            }
            if(playerStats.shroudAnimations.shroudMana.size()>0){
            	playerStats.shroudAnimations.moveAnimatedShroud((int)(((constant*4)+3) + findRatio((constant*4)+3,
        				(constant*13)-3)*((float)(playerStats.getPlayerMaxMana()/2) 
        						/ (float)(playerStats.getPlayerMaxMana()))),(((20+13)* constant))-3,0);
            	for (int i = 0; i < playerStats.shroudAnimations.shroudMana.size();i++){
            		int X = playerStats.shroudAnimations.shroudMana.get(i)._currentX;
            		int Y = playerStats.shroudAnimations.shroudMana.get(i)._currentY;
            		myText.setColor(Color.BLUE);
            		if(!zoomer.getZoom() || playerStats.shroudAnimations.shroudMana.get(i).unZoom){
            			printAnimatedGraphics(X,Y,myText,canvas,100, constant/3);
            		}else{
            			printAnimatedGraphics(X,Y,myText,canvas,100, 2*constant/3);
            		}
            	}
            }
            if(playerStats.shroudAnimations.rippleAnimation.size()>0){
            	//myPaint.setStyle(Paint.Style.STROKE); 
            	playerStats.shroudAnimations.moveRipple();
            	for (int i = 0; i < playerStats.shroudAnimations.rippleAnimation.size();i++){
            		int X = playerStats.shroudAnimations.rippleAnimation.get(i)._currentX;
            		int Y = playerStats.shroudAnimations.rippleAnimation.get(i)._currentY;
            		switch(playerStats.shroudAnimations.rippleAnimation.get(i).color){
            			case 0:myPaint.setColor(Color.GREEN);break;
            			case 1:myPaint.setColor(Color.YELLOW);break;
            			case 2:myPaint.setColor(Color.RED);break;
            			case 3:myPaint.setColor(Color.BLUE);break;
            		}
            		if(!zoomer.getZoom() || playerStats.shroudAnimations.rippleAnimation.get(i).unZoom){
            			printAnimatedGraphics(X,Y,myPaint,canvas,100,(int)(constant*playerStats.shroudAnimations.rippleAnimation.get(i)._percent)/100);
            		}else{
            			printAnimatedGraphics(X,Y,myPaint,canvas,100,(int)(2*constant*playerStats.shroudAnimations.rippleAnimation.get(i)._percent)/100);
            		}
            	}
            }
            if(playerStats.shroudAnimations.deathBubbles.size()>0){
            	int bVar = constant/5;
            	//myPaint.setStyle(Paint.Style.FILL); 
            	playerStats.shroudAnimations.moveAnimatedShroud(0,0,2);
            	for (int i = 0; i < playerStats.shroudAnimations.deathBubbles.size();i++){
            		int X = playerStats.shroudAnimations.deathBubbles.get(i)._currentX;
            		int Y = playerStats.shroudAnimations.deathBubbles.get(i)._currentY;
            		switch(playerStats.shroudAnimations.deathBubbles.get(i).color){
        				case 0:myText.setColor(Color.GREEN);break;
        				//1=Purple
        				case 1:myText.setColor(0xff9900CC);break;
        				case 2:myText.setColor(Color.RED);break;
        				case 3:myText.setColor(Color.BLUE);break;
        				case 4:myText.setColor(Color.YELLOW);break;
        				case 5:myText.setColor(0xFF99FF);break;
            		}
            		//canvas.drawLine(0, 0, 20, 20, paint);
                    //canvas.drawLine(20, 0, 0, 20, paint);
            		
            		if(!zoomer.getZoom() || playerStats.shroudAnimations.deathBubbles.get(i).unZoom){
            			if(playerStats.shroudAnimations.deathBubbles.get(i)._percent<90){
                			printAnimatedGraphics(X,Y,myText,canvas,100,constant/5);
                		}else{
                			myText.setAlpha(100);
                			canvas.drawLine(X-bVar, Y-bVar, X+bVar, Y+bVar, myText);
                			canvas.drawLine(X-bVar, Y, X+bVar, Y, myText);
                            canvas.drawLine(X-bVar, Y+bVar, X+bVar, Y-bVar, myText);
                            canvas.drawLine(X, Y+bVar, X, Y-bVar, myText);
                		}
            		}else{
            			if(playerStats.shroudAnimations.deathBubbles.get(i)._percent<90){
                			printAnimatedGraphics(X,Y,myText,canvas,100,(2*constant)/5);
                		}else{
                			myText.setAlpha(100);
                			canvas.drawLine(X-(bVar*2), Y-(bVar*2), X+(bVar*2), Y+(bVar*2), myText);
                			canvas.drawLine(X-(bVar*2), Y, X+(bVar*2), Y, myText);
                            canvas.drawLine(X-(bVar*2), Y+(bVar*2), X+(bVar*2), Y-(bVar*2), myText);
                            canvas.drawLine(X, Y+(bVar*2), X, Y-(bVar*2), myText);
                		}
            		}
            		//If the bubbles have somewhere to go
            		//if(playerStats.shroudAnimations.deathBubbles.get(i)._destX!=-1){
            			//Look for a place be
            		//	for(int j=playerStats.shroudAnimations.deathBubbles.get(i)._startX;j<playerStats.shroudAnimations.deathBubbles.get(i)._destX;j+=constant/5){
            		//		if(!findValue(playerStats.shroudAnimations.deathBubbles,j)){
            		//			System.out.println(j);
            		//			playerStats.shroudAnimations.addKillBubbles(j, 
            		//				playerStats.shroudAnimations.deathBubbles.get(i)._startY, 
            		//				playerStats.shroudAnimations.deathBubbles.get(i).color,
            		//				true);
            		//			break;
            		//		}
            		//	}
            		//}
            	}
            }
            /*if(playerStats.shroudAnimations.deathBubbles.size()>0){
            	for (int i = 0; i < playerStats.shroudAnimations.deathBubbles.size();i++){
            		if(playerStats.shroudAnimations.deathBubbles.get(i)._destX!=-1){
            			for(int j=playerStats.shroudAnimations.deathBubbles.get(i)._startX;j<playerStats.shroudAnimations.deathBubbles.get(i)._destX;j+=2){
            				if(!findValue(playerStats.shroudAnimations.deathBubbles,j)){
            					playerStats.shroudAnimations.addKillBubbles(j, 
            						playerStats.shroudAnimations.deathBubbles.get(i)._startY, 
            						playerStats.shroudAnimations.deathBubbles.get(i).color,
            						true);
            					break;
            				}
            			}
            		}
            	}
            }*/
            if(playerStats.shroudAnimations.damageAnimation.size()>0){
            	int bVar = constant/5;
            	//myPaint.setStyle(Paint.Style.FILL); 
            	playerStats.shroudAnimations.moveAnimatedShroud(0,0,3);
            	for (int i = 0; i < playerStats.shroudAnimations.damageAnimation.size();i++){
            		int X = playerStats.shroudAnimations.damageAnimation.get(i)._currentX;
            		int Y = playerStats.shroudAnimations.damageAnimation.get(i)._currentY;
            		switch(playerStats.shroudAnimations.damageAnimation.get(i).color){
    					case 0:myText.setColor(Color.GREEN);break;
    					case 1:myText.setColor(Color.RED);break;
    					case 2:myText.setColor(Color.BLUE);break;
    					case 3:myText.setColor(Color.YELLOW);break;
            		}
            		myText.setTextAlign(Paint.Align.CENTER);
        			//myPaint.setStyle(Paint.Style.FILL); 
            		
            		if(!zoomer.getZoom() || playerStats.shroudAnimations.damageAnimation.get(i).unZoom){
            			myText.setTextSize(textScaler + playerStats.shroudAnimations.damageAnimation.get(i).size);
            			//myPaint.setStrokeWidth(1);
            			if(playerStats.shroudAnimations.damageAnimation.get(i)._percent<90){
            				canvas.drawText(playerStats.shroudAnimations.damageAnimation.get(i).word,X, Y, myText);
                		}else{
                			myText.setAlpha(100);
                			canvas.drawLine(X-bVar, Y-bVar, X+bVar, Y+bVar, myText);
                			canvas.drawLine(X-bVar, Y, X+bVar, Y, myText);
                            canvas.drawLine(X-bVar, Y+bVar, X+bVar, Y-bVar, myText);
                            canvas.drawLine(X, Y+bVar, X, Y-bVar, myText);
                		}
            		}
            		else{
            			myText.setTextSize(textScaler + playerStats.shroudAnimations.damageAnimation.get(i).size+6);
            			//myPaint.setStrokeWidth(3);
            			if(playerStats.shroudAnimations.damageAnimation.get(i)._percent<90){
            				canvas.drawText(playerStats.shroudAnimations.damageAnimation.get(i).word,X, Y, myText);
                		}else{
                			myText.setAlpha(100);
                			canvas.drawLine(X-(bVar*2), Y-(bVar*2), X+(bVar*2), Y+(bVar*2), myText);
                			canvas.drawLine(X-(bVar*2), Y, X+(bVar*2), Y, myText);
                            canvas.drawLine(X-(bVar*2), Y+(bVar*2), X+(bVar*2), Y-(bVar*2), myText);
                            canvas.drawLine(X, Y+(bVar*2), X, Y-(bVar*2), myText);
                		}
            		}
            		
            	}
            }
        }
        
        public boolean findValue(ArrayList<slopeAwesome> List, int value){
        	boolean found = false;
        	for (int i = 0; i < List.size();i++){
        		if(List.get(i)._startX == value){
        			found = true;
        		}
        	}
        	return found;
        }
        
        public int returnTotalCost(int cost){
        	return (int) (cost * (1-playerStats.shopDiscount));
        }
        
        public void printPlayerModifiers(ClassGameStats playerData, int X, int Y, Canvas canvas, int constant){
        	Bitmap bitmap;
        	int movement = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (playerData.playerNumber(i)){
        			//System.out.println("True: " + i + " " + X + ":" + Y +"\n");
        			bitmap = mods[i];
                	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), 
                			mod1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),constant,false), true);
        			canvas.drawBitmap(bitmap, X, Y-movement, null);
        			movement+=bitmap.getHeight();
        			//tutorialMessages.addMessage("\tCharacter Modifier",
        			//		"You Have A Modifier Attached To Your Character (Look At The Picture Directly To Your Character's Left). " +
        			//		"Some Modifiers Are Good While Others Can Be Bad. " +
        			//		"Any Magic Ailments Can Be Cured With Mana Potions," +
        			//		" While Physical Ailments Can Be Cured With Health Potions. " +
        			//		"Leveling Up Cures All Ailments, and Does Not Effect Beneficial Modifiers. Tap Player Info On " +
        			//		"The Home Screen To Learn More About Modifiers",24);
        			//tutorialMessages.addMessage("\tAilments","You Recieved An Ailment From An Enemy. Magic Ailments Are Curable Through The Mana Potions" +
        			//		" While Physical Ailments Are Curable With Health Potions. Leveling Up Cures All Ailments",24);
        		}
        	}
        }
        
        public void printModifiers(ClassEnemyStats enemy, int X, int Y, Canvas canvas, int HUDConstant){
        	Bitmap bitmap;
        	int movement = 0;
        	for(int i = 0; i<mods.length;i++){
        		if (enemy.modNumber(i)){
        			bitmap = mods[i];
                	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), mod1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),HUDConstant,false), true);
        			canvas.drawBitmap(bitmap, (X*HUDConstant)+movement, (Y* HUDConstant), null);
        			movement+=bitmap.getWidth();
        			//tutorialMessages.addMessage("Enemy Modifier","You Have Encountered An Enemy With A Special Ability. These" +
        			//		" Take Effect Whenever An Enemy Is Attacked. For More Information On Enemy Abilities Tap The Player Info Tab" +
        			//		" In The Menu Screen",25);
        		}
        	}
        }
        
        public void drawSpellSlots(Canvas canvas, boolean playerScreen, Paint myPaint, int HUDConstant){
        	Bitmap bitmap;
        	for(int i = 0; i < playerStats.currentGlyphs.length; i++){
        		if (playerStats.currentGlyphs[i] == 0){
        			bitmap = glyphsStatic[2];
        		}
        		else{
        			bitmap = glyphsStatic[playerStats.currentGlyphs[i]-1];
        		}
        		bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (HUDConstant*1.5),false), true);
        		canvas.drawBitmap(bitmap, (HUDConstant*(14)) + (i*(HUDConstant+HUDConstant/2))+(-6+(i*3)), (((20+11)* HUDConstant)+ HUDConstant/2), null);
        		if (i == playerStats.selectedSpell){
        			bitmap = tileStatic[5];
        			bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (HUDConstant*1.5),false), true);
            		canvas.drawBitmap(bitmap, (HUDConstant*(14)) + (i*(HUDConstant+HUDConstant/2))+(-6+(i*3)), (((20+11)* HUDConstant)+ HUDConstant/2), null);
            		//if (playerScreen && playerStats.currentGlyphs[i] != 0){
            			myPaint.setStrokeWidth(1);
            			myPaint.setTextAlign(Paint.Align.CENTER);
            			myPaint.setStyle(Paint.Style.STROKE); 
            			myPaint.setTextSize(16);
            			if (playerScreen && playerStats.currentGlyphs[i] != 0){
            				bitmap = tileStatic[6];
                        	bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), icon1.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),HUDConstant*2,false), true);
                			canvas.drawBitmap(bitmap, (16*HUDConstant), ((20+3)* HUDConstant)+ HUDConstant/2, null);
                			//Writes the cost of the spell
                			myPaint.setColor(Color.GRAY);
                			myPaint.setStyle(Paint.Style.FILL); 
                			canvas.drawCircle((17*HUDConstant), (28)* HUDConstant - HUDConstant/2, HUDConstant, myPaint);
                			myPaint.setColor(Color.YELLOW);
                			canvas.drawCircle((17*HUDConstant), (28)* HUDConstant - HUDConstant/2, HUDConstant-3, myPaint);
                			myPaint.setColor(Color.GRAY);
                			canvas.drawRect((14*HUDConstant), (26)* HUDConstant, (20*HUDConstant), (28)* HUDConstant - HUDConstant/2, myPaint);
                			myPaint.setColor(Color.CYAN);
                			canvas.drawRect((14*HUDConstant)+3, (26)* HUDConstant+3, (20*HUDConstant)-3, (28)* HUDConstant - HUDConstant/2-3, myPaint);
                			myPaint.setColor(Color.BLACK);
                			canvas.drawText(""+playerStats.playerCost(playerStats.currentGlyphs[i]), (17*HUDConstant), (28)* HUDConstant+3, myPaint);
            				canvas.drawText(Draws.glyphStrings[playerStats.currentGlyphs[i]-1], (17*HUDConstant), (20+7)* HUDConstant, myPaint);
            				
            				myPaint.setColor(Color.WHITE);
            				//myPaint.setStyle(Paint.Style.FILL); 
            				myPaint.setTextSize(10);
            				breakDrawText(Draws.glyphDescriptions[playerStats.currentGlyphs[i]-1], canvas, myPaint,17,(float)29.5, HUDConstant);
            				//breakDrawText("Cost: " + playerStats.returnCost(playerStats.currentGlyphs[i]), canvas, myPaint,17,29);
            				// + "\nCost: " + playerStats.(playerStats.currentGlyphs[i]
            			}else if (playerScreen && playerStats.currentGlyphs[i] == 0){
            				canvas.drawText("No Spell", (17*HUDConstant), (20+7)* HUDConstant, myPaint);
            				myPaint.setStyle(Paint.Style.FILL); 
            				myPaint.setTextSize(10);
            				breakDrawText("This part of your mind does not know any spells", canvas, myPaint,17,29, HUDConstant);
            			}
            		//}
        		}
        		if (playerStats.returnOffense(playerStats.currentGlyphs[i]) == 1){
        			if (playerScreen){
        				bitmap = tileStatic[3];
        				bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (HUDConstant*1.5),false), true);
        				canvas.drawBitmap(bitmap, (HUDConstant*(14)) + (i*(HUDConstant+HUDConstant/2))+(-6+(i*3)), (((20+11)* HUDConstant)+ HUDConstant/2), null);
        			}
        		}else if (playerStats.returnOffense(playerStats.currentGlyphs[i]) == -1){
        			if (!playerScreen){
        				bitmap = tileStatic[3];
        				bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), graphic.returnMatrix(bitmap.getWidth(),bitmap.getHeight(),(int) (HUDConstant*1.5),false), true);
        				canvas.drawBitmap(bitmap, (HUDConstant*(14)) + (i*(HUDConstant+HUDConstant/2))+(-6+(i*3)), (((20+11)* HUDConstant)+ HUDConstant/2), null);
        			}
        		}
        	}
        }
        
        public void breakDrawText(String text, Canvas canvas, Paint myPaint, float left, float top, int HUDConstant){
        	int count, pos, charsOnLine = 20;
        	String[] temp;
        	temp = text.split(" ");
        	String newString = "";
        	myPaint.setStrokeWidth(1);
        	myPaint.setStyle(Paint.Style.FILL); 
        	
        	if (text.length()>60){
        		int textSize = 10 - (text.length() - 60)/10;
        		myPaint.setTextSize(textScaler + textSize);
        		charsOnLine += (10-textSize) * (10-textSize);
        	}else{
        		myPaint.setTextSize(textScaler + 10);
        	}
        	//number of lines
        	count = 0;
        	//position in the string array
        	pos = 0;
        	while(pos < temp.length){
        		for (;newString.length() < charsOnLine && pos < temp.length; pos++){
        			newString += temp[pos]+" ";
        			//if (temp[pos].contains("\n")){
        			//	pos++;
        			//	break;
        			//}
            	}
        		//left = 17
        		//right = 29
        		canvas.drawText(newString, (int)(((left)*HUDConstant)), (int)(((top)* HUDConstant)+ (count*(2*HUDConstant/3))), myPaint);
        		newString = "";
        		count++;
        	}
        }
        
        //@Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            // Auto-generated method stub
        }
 
        //@Override
        public void surfaceCreated(SurfaceHolder holder) {
        	if(_thread.getState() == Thread.State.TERMINATED)
            {
        		getHolder().addCallback(this);
               _thread = new TutorialThread(getHolder(), this);
            }
        	
        		//_thread = new TutorialThread(getHolder(), this);
        		_thread.setRunning(true);
        		_thread.start();
        }
 
        //@Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            // simply copied from sample application LunarLander:
            // we have to tell thread to shut down & wait for it to finish, or else
            // it might touch the Surface after we return and explode
            boolean retry = true;
            	_thread.setRunning(false);
            	while (retry) {
            		try {
            			_thread.join();
            			retry = false;
            			//System.out.println("All Threads Destroyed!!!");
            		} catch (InterruptedException e) {
            			System.out.println(e);
            			// we will try it again and again...
                }
            }
        }
    }
 
    class TutorialThread extends Thread {
        private SurfaceHolder _surfaceHolder;
        private Panel _panel;
        private boolean gameOver,endDrawn,animationMade;
        private boolean _run = false;
 
        
        
        public TutorialThread(SurfaceHolder surfaceHolder, Panel panel) {
            _surfaceHolder = surfaceHolder;
            _panel = panel;
            gameOver = false;
            endDrawn = false;
            animationMade = false;
        }
        public void gameDone(){
        	gameOver = true;
        }
        
        public boolean getGameStatus(){
        	return gameOver;
        }
        
        public boolean getEndStatus(){
        	return endDrawn;
        }
        
        public void setRunning(boolean run) {
            _run = run;
        }
 
        public SurfaceHolder getSurfaceHolder() {
            return _surfaceHolder;
        }
 
        @SuppressLint("WrongCall")
		@Override
        public void run() {
            Canvas c;
            while (_run) {
                c = null;
                try {
                    c = _surfaceHolder.lockCanvas(null);
                    synchronized (_surfaceHolder) {
                        _panel.onDraw(c);
                        _panel.tutorialMessages.showMessages(false);
                    }
                } finally {
                    // do this in a finally so that if an exception is thrown
                    // during the above, we don't leave the Surface in an
                    // inconsistent state
                    if (c != null) {
                        _surfaceHolder.unlockCanvasAndPost(c);
                    }
                }
            }
        }
    }

    
    /*public int calculateProgress(int exp){
		int i = 1;
		int lower, higher;
		float percent;
		while((i*10000)< exp){
			i++;
		}
		lower = exp - ((i-1)*10000);
		higher = ((i)*10000) - ((i-1)*10000);
		percent = ((float)lower)/((float)higher);
		return (int) (percent*100);
	}*/
    
    
    /*public int calculateLevel(int exp){
		int i = 1;
		while((i*10000)< exp){
			i++;
		}
		return i-1;
	}*/
    
    //public int returnLevelExp(int level){
    // 	return level * 10000;
    //}
    class settingsHolder{
    	//TODO Make toast similar to settingsmenu
    }
}
